From f4dd443b777906daee38788fd5444d934ce00740 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Fri, 6 Mar 2026 01:48:19 -0800 Subject: [PATCH] Replace manual memory management with FinalizationRegistry (#1908) Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1908 Fixes https://github.com/facebook/yoga/issues/1818 Fixes https://github.com/facebook/yoga/issues/1572 Yoga's JavaScript API currently requires users to manually call `node.free()`, `node.freeRecursive()`, or `config.free()` to release WASM memory. This is error-prone and unusual for a JavaScript library. This diff uses `FinalizationRegistry` (available in all modern JS engines) to automatically free WASM memory when JS objects are garbage collected, removing this footgun entirely. Changes: - Added `FinalizationRegistry` instances for `Node` and `Config` in `wrapAssembly.ts`. When a `NodeImpl`/`ConfigImpl` is constructed, it is registered with the appropriate registry. The weak reference callback receives the WASM pointer and calls the appropriate C free function. - The Node finalizer calls `YGNodeFinalize` (not `YGNodeFree`) to safely deallocate without disconnecting nodes from their owner/children, since an entire tree may be garbage collected together. - Removed `free()` and `freeRecursive()` from the public `Node` type and `free()` from the public `Config` type. - Removed `Yoga.Node.destroy()` and `Yoga.Config.destroy()` factory methods. - Fixed `setDirtiedFunc` to use `WeakRef(this)` instead of capturing `this` directly in the closure stored in the dirtied func Map. The previous `() => dirtiedFunc(this)` pattern created a strong reference from the Map to the Node, preventing GC of detached nodes with a dirtied func set. - Updated `gentest-javascript.js` to stop generating `try`/`finally` cleanup blocks and `let root` declarations in test prologues/epilogues. - Removed all `free()`/`freeRecursive()`/`config.free()` calls from 25 generated test files and 9 hand-written test files. - Re-signed all generated test files with signedsource. - Updated `README.md` to remove manual memory management documentation. Reviewed By: cipolleschi Differential Revision: D95014519 --- gentest/gentest-javascript.js | 25 +- javascript/README.md | 13 - javascript/src/wrapAssembly.ts | 59 +- .../tests/Benchmarks/YGBenchmark.test.ts | 4 - javascript/tests/YGAlignBaselineTest.test.ts | 196 +- javascript/tests/YGComputedBorderTest.test.ts | 2 - javascript/tests/YGComputedMarginTest.test.ts | 2 - .../tests/YGComputedPaddingTest.test.ts | 2 - javascript/tests/YGDirtiedTest.test.ts | 8 - javascript/tests/YGErrataTest.test.ts | 6 - javascript/tests/YGFlexBasisAuto.test.ts | 2 - javascript/tests/YGMeasureCacheTest.test.ts | 2 - javascript/tests/YGMeasureTest.test.ts | 4 - .../generated/YGAbsolutePositionTest.test.ts | 3160 ++--- .../generated/YGAlignContentTest.test.ts | 10640 +++++++------- .../tests/generated/YGAlignItemsTest.test.ts | 4535 +++--- .../tests/generated/YGAlignSelfTest.test.ts | 453 +- .../tests/generated/YGAndroidNewsFeed.test.ts | 557 +- .../tests/generated/YGAspectRatioTest.test.ts | 374 +- javascript/tests/generated/YGAutoTest.test.ts | 561 +- .../tests/generated/YGBorderTest.test.ts | 379 +- .../tests/generated/YGBoxSizingTest.test.ts | 4716 +++---- .../tests/generated/YGDimensionTest.test.ts | 170 +- .../generated/YGDisplayContentsTest.test.ts | 144 +- .../tests/generated/YGDisplayTest.test.ts | 1926 ++- ...GFlexBasisFitContentInMainAxisTest.test.ts | 817 +- .../generated/YGFlexDirectionTest.test.ts | 8241 +++++------ javascript/tests/generated/YGFlexTest.test.ts | 1146 +- .../tests/generated/YGFlexWrapTest.test.ts | 3724 +++-- javascript/tests/generated/YGGapTest.test.ts | 6053 ++++---- .../generated/YGIntrinsicSizeTest.test.ts | 5597 ++++---- .../generated/YGJustifyContentTest.test.ts | 3792 +++-- .../tests/generated/YGMarginTest.test.ts | 3358 ++--- .../generated/YGMinMaxDimensionTest.test.ts | 2444 ++-- .../tests/generated/YGPaddingTest.test.ts | 545 +- .../tests/generated/YGPercentageTest.test.ts | 3027 ++-- .../tests/generated/YGRoundingTest.test.ts | 2069 ++- .../generated/YGSizeOverflowTest.test.ts | 311 +- .../generated/YGStaticPositionTest.test.ts | 11688 ++++++++-------- website/src/components/YogaViewer.tsx | 1 - 40 files changed, 37665 insertions(+), 43088 deletions(-) diff --git a/gentest/gentest-javascript.js b/gentest/gentest-javascript.js index f3faf01628..825c7ca8d4 100644 --- a/gentest/gentest-javascript.js +++ b/gentest/gentest-javascript.js @@ -59,7 +59,6 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, { this.push(`${testFn}('${name}', () => {`); this.pushIndent(); this.push('const config = Yoga.Config.create();'); - this.push('let root;'); this.push(''); if (experiments.length > 0) { @@ -70,39 +69,17 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, { } this.push(''); } - - this.push('try {'); - this.pushIndent(); }, }, emitTestTreePrologue: { value: function (nodeName) { - if (nodeName === 'root') { - this.push(`root = Yoga.Node.create(config);`); - } else { - this.push(`const ${nodeName} = Yoga.Node.create(config);`); - } + this.push(`const ${nodeName} = Yoga.Node.create(config);`); }, }, emitTestEpilogue: { value: function (_experiments) { - this.popIndent(); - this.push('} finally {'); - this.pushIndent(); - - this.push("if (typeof root !== 'undefined') {"); - this.pushIndent(); - this.push('root.freeRecursive();'); - this.popIndent(); - this.push('}'); - this.push(''); - this.push('config.free();'); - - this.popIndent(); - this.push('}'); - this.popIndent(); this.push('});'); }, diff --git a/javascript/README.md b/javascript/README.md index 6a9df41971..c72280b389 100644 --- a/javascript/README.md +++ b/javascript/README.md @@ -13,19 +13,6 @@ const node = Yoga.Node.create(); node.setAlignContent(Align.Center); ``` -Objects created by `Yoga.<>.create()` are not automatically garbage collected and should be freed once they are no longer in use. - -```ts -// Free a config -config.free(); - -// Free a tree of Nodes -node.freeRecursive(); - -// Free a single Node -node.free(); -``` - ## Requirements `yoga-layout` requires a toolchain that supports ES Modules and top-level await. diff --git a/javascript/src/wrapAssembly.ts b/javascript/src/wrapAssembly.ts index f7a5653a15..cbb51a4564 100644 --- a/javascript/src/wrapAssembly.ts +++ b/javascript/src/wrapAssembly.ts @@ -48,7 +48,6 @@ type Value = { }; export type Config = { - free(): void; isExperimentalFeatureEnabled(feature: ExperimentalFeature): boolean; setExperimentalFeatureEnabled( feature: ExperimentalFeature, @@ -77,8 +76,6 @@ export type Node = { direction?: Direction, ): void; copyStyle(node: Node): void; - free(): void; - freeRecursive(): void; getAlignContent(): Align; getAlignItems(): Align; getAlignSelf(): Align; @@ -263,13 +260,11 @@ export type Node = { export type Yoga = { Config: { create(): Config; - destroy(config: Config): void; }; Node: { create(config?: Config): Node; createDefault(): Node; createWithConfig(config: Config): Node; - destroy(node: Node): void; }; } & typeof YGEnums; @@ -365,16 +360,24 @@ export default function wrapAssembly(lib: any): Yoga { } } + // --- FinalizationRegistry for automatic cleanup --- + const configRegistry = new FinalizationRegistry((ptr: number) => { + lib._YGConfigFree(ptr); + }); + + const nodeRegistry = new FinalizationRegistry((ptr: number) => { + lib._yogaMeasureFuncs.delete(ptr); + lib._yogaDirtiedFuncs.delete(ptr); + lib._YGNodeFinalize(ptr); + }); + // --- Config class --- class ConfigImpl { _ptr: number; constructor(ptr: number) { this._ptr = ptr; - } - - free(): void { - lib._YGConfigFree(this._ptr); + configRegistry.register(this, ptr, this); } setExperimentalFeatureEnabled( @@ -423,6 +426,7 @@ export default function wrapAssembly(lib: any): Yoga { this._ptr = ptr; this._children = []; this._parent = null; + nodeRegistry.register(this, ptr, this); } // --- Tree hierarchy --- @@ -454,31 +458,6 @@ export default function wrapAssembly(lib: any): Yoga { } // --- Lifecycle --- - free(): void { - lib._yogaMeasureFuncs.delete(this._ptr); - lib._yogaDirtiedFuncs.delete(this._ptr); - - // Clear JS tree references - if (this._parent) { - const idx = this._parent._children.indexOf(this); - if (idx !== -1) { - this._parent._children.splice(idx, 1); - } - this._parent = null; - } - this._children = []; - - lib._YGNodeFree(this._ptr); - } - - freeRecursive(): void { - // Walk children in JS, calling freeRecursive on each - while (this._children.length > 0) { - this._children[0].freeRecursive(); - } - this.free(); - } - reset(): void { lib._yogaMeasureFuncs.delete(this._ptr); lib._yogaDirtiedFuncs.delete(this._ptr); @@ -920,7 +899,11 @@ export default function wrapAssembly(lib: any): Yoga { setDirtiedFunc(dirtiedFunc: DirtiedFunction | null): void { if (dirtiedFunc) { - lib._yogaDirtiedFuncs.set(this._ptr, () => dirtiedFunc(this)); + const nodeWeakRef = new WeakRef(this); + lib._yogaDirtiedFuncs.set(this._ptr, () => { + const node = nodeWeakRef.deref(); + if (node) dirtiedFunc(node); + }); lib._jswrap_YGNodeSetDirtiedFunc(this._ptr); } else { this.unsetDirtiedFunc(); @@ -1011,9 +994,6 @@ export default function wrapAssembly(lib: any): Yoga { create(): Config { return new ConfigImpl(lib._YGConfigNew()); }, - destroy(config: Config): void { - (config as ConfigImpl).free(); - }, }, Node: { create(config?: Config): Node { @@ -1032,9 +1012,6 @@ export default function wrapAssembly(lib: any): Yoga { lib._YGNodeNewWithConfig((config as ConfigImpl)._ptr), ); }, - destroy(node: Node): void { - (node as NodeImpl).free(); - }, }, ...YGEnums, }; diff --git a/javascript/tests/Benchmarks/YGBenchmark.test.ts b/javascript/tests/Benchmarks/YGBenchmark.test.ts index e65f4ddb52..7ebb795afd 100644 --- a/javascript/tests/Benchmarks/YGBenchmark.test.ts +++ b/javascript/tests/Benchmarks/YGBenchmark.test.ts @@ -27,7 +27,6 @@ YGBENCHMARK('Stack with flex', () => { } root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); - root.freeRecursive(); }); YGBENCHMARK('Align stretch in undefined axis', () => { @@ -43,7 +42,6 @@ YGBENCHMARK('Align stretch in undefined axis', () => { } root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); - root.freeRecursive(); }); YGBENCHMARK('Nested flex', () => { @@ -67,7 +65,6 @@ YGBENCHMARK('Nested flex', () => { } root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); - root.freeRecursive(); }); YGBENCHMARK('Huge nested layout', () => { @@ -110,5 +107,4 @@ YGBENCHMARK('Huge nested layout', () => { } root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); - root.freeRecursive(); }); diff --git a/javascript/tests/YGAlignBaselineTest.test.ts b/javascript/tests/YGAlignBaselineTest.test.ts index fd03ddfe6c..859894577c 100644 --- a/javascript/tests/YGAlignBaselineTest.test.ts +++ b/javascript/tests/YGAlignBaselineTest.test.ts @@ -9,116 +9,96 @@ import Yoga from 'yoga-layout'; test('align_baseline_parent_using_child_in_column_as_reference', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); - root.setWidth(1000); - root.setHeight(1000); - root.setAlignItems(Yoga.ALIGN_BASELINE); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); - root_child0.setWidth(500); - root_child0.setHeight(600); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); - root_child1.setWidth(500); - root_child1.setHeight(800); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); - root_child1_child0.setWidth(500); - root_child1_child0.setHeight(300); - root_child1.insertChild(root_child1_child0, 0); - - const root_child1_child1 = Yoga.Node.create(config); - root_child1_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); - root_child1_child1.setWidth(500); - root_child1_child1.setHeight(400); - root_child1_child1.setIsReferenceBaseline(true); - root_child1.insertChild(root_child1_child1, 1); - - root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(500); - expect(root_child1.getComputedTop()).toBe(0); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - - expect(root_child1_child1.getComputedLeft()).toBe(0); - expect(root_child1_child1.getComputedTop()).toBe(300); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + const root = Yoga.Node.create(config); + root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); + root.setWidth(1000); + root.setHeight(1000); + root.setAlignItems(Yoga.ALIGN_BASELINE); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); + root_child0.setWidth(500); + root_child0.setHeight(600); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); + root_child1.setWidth(500); + root_child1.setHeight(800); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); + root_child1_child0.setWidth(500); + root_child1_child0.setHeight(300); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); + root_child1_child1.setWidth(500); + root_child1_child1.setHeight(400); + root_child1_child1.setIsReferenceBaseline(true); + root_child1.insertChild(root_child1_child1, 1); + + root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(500); + expect(root_child1.getComputedTop()).toBe(0); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + + expect(root_child1_child1.getComputedLeft()).toBe(0); + expect(root_child1_child1.getComputedTop()).toBe(300); }); test('align_baseline_parent_using_child_in_row_as_reference', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); - root.setWidth(1000); - root.setHeight(1000); - root.setAlignItems(Yoga.ALIGN_BASELINE); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); - root_child0.setWidth(500); - root_child0.setHeight(600); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); - root_child1.setWidth(500); - root_child1.setHeight(800); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); - root_child1_child0.setWidth(500); - root_child1_child0.setHeight(500); - root_child1.insertChild(root_child1_child0, 0); - - const root_child1_child1 = Yoga.Node.create(config); - root_child1_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); - root_child1_child1.setWidth(500); - root_child1_child1.setHeight(400); - root_child1_child1.setIsReferenceBaseline(true); - root_child1.insertChild(root_child1_child1, 1); - - root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(500); - expect(root_child1.getComputedTop()).toBe(200); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - - expect(root_child1_child1.getComputedLeft()).toBe(500); - expect(root_child1_child1.getComputedTop()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + const root = Yoga.Node.create(config); + root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); + root.setWidth(1000); + root.setHeight(1000); + root.setAlignItems(Yoga.ALIGN_BASELINE); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); + root_child0.setWidth(500); + root_child0.setHeight(600); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); + root_child1.setWidth(500); + root_child1.setHeight(800); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); + root_child1_child0.setWidth(500); + root_child1_child0.setHeight(500); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); + root_child1_child1.setWidth(500); + root_child1_child1.setHeight(400); + root_child1_child1.setIsReferenceBaseline(true); + root_child1.insertChild(root_child1_child1, 1); + + root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(500); + expect(root_child1.getComputedTop()).toBe(200); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + + expect(root_child1_child1.getComputedLeft()).toBe(500); + expect(root_child1_child1.getComputedTop()).toBe(0); }); diff --git a/javascript/tests/YGComputedBorderTest.test.ts b/javascript/tests/YGComputedBorderTest.test.ts index 09e98f679a..39e4f399e5 100644 --- a/javascript/tests/YGComputedBorderTest.test.ts +++ b/javascript/tests/YGComputedBorderTest.test.ts @@ -22,6 +22,4 @@ test('border_start', () => { expect(root.getComputedBorder(Yoga.EDGE_LEFT)).toBe(0); expect(root.getComputedBorder(Yoga.EDGE_RIGHT)).toBe(10); - - root.freeRecursive(); }); diff --git a/javascript/tests/YGComputedMarginTest.test.ts b/javascript/tests/YGComputedMarginTest.test.ts index 3b3944e557..0978f8264c 100644 --- a/javascript/tests/YGComputedMarginTest.test.ts +++ b/javascript/tests/YGComputedMarginTest.test.ts @@ -22,6 +22,4 @@ test('margin_start', () => { expect(root.getComputedMargin(Yoga.EDGE_LEFT)).toBe(0); expect(root.getComputedMargin(Yoga.EDGE_RIGHT)).toBe(10); - - root.freeRecursive(); }); diff --git a/javascript/tests/YGComputedPaddingTest.test.ts b/javascript/tests/YGComputedPaddingTest.test.ts index 75653f2233..2218dfe7e4 100644 --- a/javascript/tests/YGComputedPaddingTest.test.ts +++ b/javascript/tests/YGComputedPaddingTest.test.ts @@ -22,6 +22,4 @@ test('padding_start', () => { expect(root.getComputedPadding(Yoga.EDGE_LEFT)).toBe(0); expect(root.getComputedPadding(Yoga.EDGE_RIGHT)).toBe(10); - - root.freeRecursive(); }); diff --git a/javascript/tests/YGDirtiedTest.test.ts b/javascript/tests/YGDirtiedTest.test.ts index 6d2fa6718d..8a47291af0 100644 --- a/javascript/tests/YGDirtiedTest.test.ts +++ b/javascript/tests/YGDirtiedTest.test.ts @@ -32,8 +32,6 @@ test('dirtied', () => { // dirtied func MUST be called ONCE. root.markDirty(); expect(dirtied).toBe(1); - - root.freeRecursive(); }); test('dirtied_propagation', () => { @@ -71,8 +69,6 @@ test('dirtied_propagation', () => { // dirtied func must NOT be called for the second time. root_child0.markDirty(); expect(dirtied).toBe(1); - - root.freeRecursive(); }); test('dirtied_hierarchy', () => { @@ -114,8 +110,6 @@ test('dirtied_hierarchy', () => { // dirtied func MUST be called in case of explicit dirtying. root_child0.markDirty(); expect(dirtied).toBe(1); - - root.freeRecursive(); }); test('dirtied_reset', () => { @@ -152,6 +146,4 @@ test('dirtied_reset', () => { // dirtied func must NOT be called after reset. root.markDirty(); expect(dirtied).toBe(1); - - root.freeRecursive(); }); diff --git a/javascript/tests/YGErrataTest.test.ts b/javascript/tests/YGErrataTest.test.ts index da186fceac..725cab03ea 100644 --- a/javascript/tests/YGErrataTest.test.ts +++ b/javascript/tests/YGErrataTest.test.ts @@ -13,8 +13,6 @@ test('errata_all_contains_example_errata', () => { expect(config.getErrata()).toBe(Yoga.ERRATA_ALL); expect(config.getErrata() & Yoga.ERRATA_STRETCH_FLEX_BASIS).not.toBe(0); - - config.free(); }); test('errata_none_omits_example_errata', () => { @@ -23,8 +21,6 @@ test('errata_none_omits_example_errata', () => { expect(config.getErrata()).toBe(Yoga.ERRATA_NONE); expect(config.getErrata() & Yoga.ERRATA_STRETCH_FLEX_BASIS).toBe(0); - - config.free(); }); test('errata_is_settable', () => { @@ -35,6 +31,4 @@ test('errata_is_settable', () => { config.setErrata(Yoga.ERRATA_NONE); expect(config.getErrata()).toBe(Yoga.ERRATA_NONE); - - config.free(); }); diff --git a/javascript/tests/YGFlexBasisAuto.test.ts b/javascript/tests/YGFlexBasisAuto.test.ts index d6e28d69ed..2b1b04202a 100644 --- a/javascript/tests/YGFlexBasisAuto.test.ts +++ b/javascript/tests/YGFlexBasisAuto.test.ts @@ -18,6 +18,4 @@ test('flex_basis_auto', () => { root.setFlexBasisAuto(); expect(root.getFlexBasis().unit).toBe(Yoga.UNIT_AUTO); - - root.freeRecursive(); }); diff --git a/javascript/tests/YGMeasureCacheTest.test.ts b/javascript/tests/YGMeasureCacheTest.test.ts index 4a95d1c685..f570caf53a 100644 --- a/javascript/tests/YGMeasureCacheTest.test.ts +++ b/javascript/tests/YGMeasureCacheTest.test.ts @@ -26,6 +26,4 @@ test('measure_once_single_flexible_child', () => { root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); expect(measureCounter.get()).toBe(1); - - root.freeRecursive(); }); diff --git a/javascript/tests/YGMeasureTest.test.ts b/javascript/tests/YGMeasureTest.test.ts index 941d424fc3..fe651f01ae 100644 --- a/javascript/tests/YGMeasureTest.test.ts +++ b/javascript/tests/YGMeasureTest.test.ts @@ -23,8 +23,6 @@ test('dont_measure_single_grow_shrink_child', () => { root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); expect(measureCounter.get()).toBe(0); - - root.freeRecursive(); }); test('dont_fail_with_incomplete_measure_dimensions', () => { @@ -65,6 +63,4 @@ test('dont_fail_with_incomplete_measure_dimensions', () => { expect(node3.getComputedWidth()).toBe(100); expect(node3.getComputedHeight()).toBe(0); - - root.freeRecursive(); }); diff --git a/javascript/tests/generated/YGAbsolutePositionTest.test.ts b/javascript/tests/generated/YGAbsolutePositionTest.test.ts index 694086e23c..04f2df4f73 100644 --- a/javascript/tests/generated/YGAbsolutePositionTest.test.ts +++ b/javascript/tests/generated/YGAbsolutePositionTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<9deb466dfc94bb340137a9e6b5d5c63d>> + * @generated SignedSource<<507896713beb89b89fd5895233bc92d4>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAbsolutePositionTest.html */ @@ -30,1835 +30,1529 @@ import { test('absolute_layout_width_height_start_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPosition(Edge.Start, 10); - root_child0.setPosition(Edge.Top, 10); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Start, 10); + root_child0.setPosition(Edge.Top, 10); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('absolute_layout_width_height_left_auto_right', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPositionAuto(Edge.Left); - root_child0.setPosition(Edge.Right, 10); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPositionAuto(Edge.Left); + root_child0.setPosition(Edge.Right, 10); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('absolute_layout_width_height_left_right_auto', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPosition(Edge.Left, 10); - root_child0.setPositionAuto(Edge.Right); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, 10); + root_child0.setPositionAuto(Edge.Right); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('absolute_layout_width_height_left_auto_right_auto', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPositionAuto(Edge.Left); - root_child0.setPositionAuto(Edge.Right); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPositionAuto(Edge.Left); + root_child0.setPositionAuto(Edge.Right); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('absolute_layout_width_height_end_bottom', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPosition(Edge.End, 10); - root_child0.setPosition(Edge.Bottom, 10); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(80); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(80); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.End, 10); + root_child0.setPosition(Edge.Bottom, 10); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(80); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(80); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('absolute_layout_start_top_end_bottom', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPosition(Edge.Start, 10); - root_child0.setPosition(Edge.Top, 10); - root_child0.setPosition(Edge.End, 10); - root_child0.setPosition(Edge.Bottom, 10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(80); - expect(root_child0.getComputedHeight()).toBe(80); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(80); - expect(root_child0.getComputedHeight()).toBe(80); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Start, 10); + root_child0.setPosition(Edge.Top, 10); + root_child0.setPosition(Edge.End, 10); + root_child0.setPosition(Edge.Bottom, 10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(80); }); test('absolute_layout_width_height_start_top_end_bottom', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPosition(Edge.Start, 10); - root_child0.setPosition(Edge.Top, 10); - root_child0.setPosition(Edge.End, 10); - root_child0.setPosition(Edge.Bottom, 10); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Start, 10); + root_child0.setPosition(Edge.Top, 10); + root_child0.setPosition(Edge.End, 10); + root_child0.setPosition(Edge.Bottom, 10); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setOverflow(Overflow.Hidden); - root.setWidth(50); - root.setHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPosition(Edge.Start, 0); - root_child0.setPosition(Edge.Top, 0); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(-50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setOverflow(Overflow.Hidden); + root.setWidth(50); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Start, 0); + root_child0.setPosition(Edge.Top, 0); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(-50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); }); test('absolute_layout_within_border', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setMargin(Edge.Left, 10); - root.setMargin(Edge.Top, 10); - root.setMargin(Edge.Right, 10); - root.setMargin(Edge.Bottom, 10); - root.setPadding(Edge.Left, 10); - root.setPadding(Edge.Top, 10); - root.setPadding(Edge.Right, 10); - root.setPadding(Edge.Bottom, 10); - root.setBorder(Edge.Left, 10); - root.setBorder(Edge.Top, 10); - root.setBorder(Edge.Right, 10); - root.setBorder(Edge.Bottom, 10); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPosition(Edge.Left, 0); - root_child0.setPosition(Edge.Top, 0); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setPositionType(PositionType.Absolute); - root_child1.setPosition(Edge.Right, 0); - root_child1.setPosition(Edge.Bottom, 0); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setPositionType(PositionType.Absolute); - root_child2.setPosition(Edge.Left, 0); - root_child2.setPosition(Edge.Top, 0); - root_child2.setMargin(Edge.Left, 10); - root_child2.setMargin(Edge.Top, 10); - root_child2.setMargin(Edge.Right, 10); - root_child2.setMargin(Edge.Bottom, 10); - root_child2.setWidth(50); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setPositionType(PositionType.Absolute); - root_child3.setPosition(Edge.Right, 0); - root_child3.setPosition(Edge.Bottom, 0); - root_child3.setMargin(Edge.Left, 10); - root_child3.setMargin(Edge.Top, 10); - root_child3.setMargin(Edge.Right, 10); - root_child3.setMargin(Edge.Bottom, 10); - root_child3.setWidth(50); - root_child3.setHeight(50); - root.insertChild(root_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(10); - expect(root.getComputedTop()).toBe(10); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - expect(root_child3.getComputedLeft()).toBe(30); - expect(root_child3.getComputedTop()).toBe(30); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(10); - expect(root.getComputedTop()).toBe(10); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - expect(root_child3.getComputedLeft()).toBe(30); - expect(root_child3.getComputedTop()).toBe(30); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Left, 10); + root.setMargin(Edge.Top, 10); + root.setMargin(Edge.Right, 10); + root.setMargin(Edge.Bottom, 10); + root.setPadding(Edge.Left, 10); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 10); + root.setPadding(Edge.Bottom, 10); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, 0); + root_child0.setPosition(Edge.Top, 0); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPositionType(PositionType.Absolute); + root_child1.setPosition(Edge.Right, 0); + root_child1.setPosition(Edge.Bottom, 0); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setPositionType(PositionType.Absolute); + root_child2.setPosition(Edge.Left, 0); + root_child2.setPosition(Edge.Top, 0); + root_child2.setMargin(Edge.Left, 10); + root_child2.setMargin(Edge.Top, 10); + root_child2.setMargin(Edge.Right, 10); + root_child2.setMargin(Edge.Bottom, 10); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setPositionType(PositionType.Absolute); + root_child3.setPosition(Edge.Right, 0); + root_child3.setPosition(Edge.Bottom, 0); + root_child3.setMargin(Edge.Left, 10); + root_child3.setMargin(Edge.Top, 10); + root_child3.setMargin(Edge.Right, 10); + root_child3.setMargin(Edge.Bottom, 10); + root_child3.setWidth(50); + root_child3.setHeight(50); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(10); + expect(root.getComputedTop()).toBe(10); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(30); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(10); + expect(root.getComputedTop()).toBe(10); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(30); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); }); test('absolute_layout_align_items_and_justify_content_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexGrow(1); - root.setWidth(110); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(60); - root_child0.setHeight(40); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(25); - expect(root_child0.getComputedTop()).toBe(30); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(25); - expect(root_child0.getComputedTop()).toBe(30); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(60); + root_child0.setHeight(40); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); }); test('absolute_layout_align_items_and_justify_content_flex_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.FlexEnd); - root.setAlignItems(Align.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setFlexGrow(1); - root.setWidth(110); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(60); - root_child0.setHeight(40); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.FlexEnd); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(60); + root_child0.setHeight(40); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); }); test('absolute_layout_justify_content_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexGrow(1); - root.setWidth(110); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(60); - root_child0.setHeight(40); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(30); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(30); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(60); + root_child0.setHeight(40); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); }); test('absolute_layout_align_items_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexGrow(1); - root.setWidth(110); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(60); - root_child0.setHeight(40); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(25); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(25); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(60); + root_child0.setHeight(40); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); }); test('absolute_layout_align_items_center_on_child_only', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setFlexGrow(1); - root.setWidth(110); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignSelf(Align.Center); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(60); - root_child0.setHeight(40); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(25); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(25); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.Center); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(60); + root_child0.setHeight(40); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); }); test('absolute_layout_align_items_and_justify_content_center_and_top_position', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexGrow(1); - root.setWidth(110); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPosition(Edge.Top, 10); - root_child0.setWidth(60); - root_child0.setHeight(40); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(25); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(25); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Top, 10); + root_child0.setWidth(60); + root_child0.setHeight(40); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); }); test('absolute_layout_align_items_and_justify_content_center_and_bottom_position', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexGrow(1); - root.setWidth(110); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPosition(Edge.Bottom, 10); - root_child0.setWidth(60); - root_child0.setHeight(40); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(25); - expect(root_child0.getComputedTop()).toBe(50); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(25); - expect(root_child0.getComputedTop()).toBe(50); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Bottom, 10); + root_child0.setWidth(60); + root_child0.setHeight(40); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); }); test('absolute_layout_align_items_and_justify_content_center_and_left_position', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexGrow(1); - root.setWidth(110); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPosition(Edge.Left, 5); - root_child0.setWidth(60); - root_child0.setHeight(40); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(5); - expect(root_child0.getComputedTop()).toBe(30); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(5); - expect(root_child0.getComputedTop()).toBe(30); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, 5); + root_child0.setWidth(60); + root_child0.setHeight(40); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); }); test('absolute_layout_align_items_and_justify_content_center_and_right_position', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexGrow(1); - root.setWidth(110); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPosition(Edge.Right, 5); - root_child0.setWidth(60); - root_child0.setHeight(40); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(45); - expect(root_child0.getComputedTop()).toBe(30); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(45); - expect(root_child0.getComputedTop()).toBe(30); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Right, 5); + root_child0.setWidth(60); + root_child0.setHeight(40); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); }); test('position_root_with_rtl_should_position_withoutdirection', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPosition(Edge.Left, 72); - root.setWidth(52); - root.setHeight(52); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(72); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(72); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPosition(Edge.Left, 72); + root.setWidth(52); + root.setHeight(52); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(72); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(72); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); }); test('absolute_layout_percentage_bottom_based_on_parent_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPosition(Edge.Top, "50%"); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setPositionType(PositionType.Absolute); - root_child1.setPosition(Edge.Bottom, "50%"); - root_child1.setWidth(10); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setPositionType(PositionType.Absolute); - root_child2.setPosition(Edge.Top, "10%"); - root_child2.setPosition(Edge.Bottom, "10%"); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(90); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(160); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(90); - expect(root_child1.getComputedTop()).toBe(90); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(90); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(160); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Top, "50%"); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPositionType(PositionType.Absolute); + root_child1.setPosition(Edge.Bottom, "50%"); + root_child1.setWidth(10); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setPositionType(PositionType.Absolute); + root_child2.setPosition(Edge.Top, "10%"); + root_child2.setPosition(Edge.Bottom, "10%"); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(90); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(160); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(90); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(160); }); test('absolute_layout_in_wrap_reverse_column_container', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.WrapReverse); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); }); test('absolute_layout_in_wrap_reverse_row_container', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.WrapReverse); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(80); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(80); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(80); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(80); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); }); test('absolute_layout_in_wrap_reverse_column_container_flex_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.WrapReverse); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignSelf(Align.FlexEnd); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexEnd); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); }); test('absolute_layout_in_wrap_reverse_row_container_flex_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.WrapReverse); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignSelf(Align.FlexEnd); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexEnd); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); }); test('percent_absolute_position_infinite_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(300); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setPositionType(PositionType.Absolute); - root_child1.setPosition(Edge.Left, "20%"); - root_child1.setPosition(Edge.Top, "20%"); - root_child1.setWidth("20%"); - root_child1.setHeight("20%"); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(0); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(300); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(60); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(60); - expect(root_child1.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(0); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(300); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(60); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(60); - expect(root_child1.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(300); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPositionType(PositionType.Absolute); + root_child1.setPosition(Edge.Left, "20%"); + root_child1.setPosition(Edge.Top, "20%"); + root_child1.setWidth("20%"); + root_child1.setHeight("20%"); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(0); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(0); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(0); }); test('absolute_layout_percentage_height_based_on_padded_parent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Top, 10); - root.setBorder(Edge.Top, 10); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(100); - root_child0.setHeight("50%"); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(45); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(45); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Top, 10); + root.setBorder(Edge.Top, 10); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(100); + root_child0.setHeight("50%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(45); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(45); }); test('absolute_layout_percentage_height_based_on_padded_parent_and_align_items_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setAlignItems(Align.Center); - root.setPadding(Edge.Top, 20); - root.setPadding(Edge.Bottom, 20); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(100); - root_child0.setHeight("50%"); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(25); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(25); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPadding(Edge.Top, 20); + root.setPadding(Edge.Bottom, 20); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(100); + root_child0.setHeight("50%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(25); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(25); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); }); test('absolute_layout_padding_left', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 100); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 100); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); }); test('absolute_layout_padding_right', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Right, 100); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Right, 100); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); }); test('absolute_layout_padding_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Top, 100); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Top, 100); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); }); test('absolute_layout_padding_bottom', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Bottom, 100); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Bottom, 100); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); }); test('absolute_layout_padding', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 10); - root_child0.setMargin(Edge.Top, 10); - root_child0.setMargin(Edge.Right, 10); - root_child0.setMargin(Edge.Bottom, 10); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setPadding(Edge.Left, 50); - root_child0_child0.setPadding(Edge.Top, 50); - root_child0_child0.setPadding(Edge.Right, 50); - root_child0_child0.setPadding(Edge.Bottom, 50); - root_child0_child0.setWidth(200); - root_child0_child0.setHeight(200); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(220); - expect(root.getComputedHeight()).toBe(220); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(220); - expect(root.getComputedHeight()).toBe(220); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 10); + root_child0.setMargin(Edge.Top, 10); + root_child0.setMargin(Edge.Right, 10); + root_child0.setMargin(Edge.Bottom, 10); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setPadding(Edge.Left, 50); + root_child0_child0.setPadding(Edge.Top, 50); + root_child0_child0.setPadding(Edge.Right, 50); + root_child0_child0.setPadding(Edge.Bottom, 50); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(220); + expect(root.getComputedHeight()).toBe(220); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(220); + expect(root.getComputedHeight()).toBe(220); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('absolute_layout_border', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 10); - root_child0.setMargin(Edge.Top, 10); - root_child0.setMargin(Edge.Right, 10); - root_child0.setMargin(Edge.Bottom, 10); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setBorder(Edge.Left, 10); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 10); - root_child0_child0.setBorder(Edge.Bottom, 10); - root_child0_child0.setWidth(200); - root_child0_child0.setHeight(200); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(220); - expect(root.getComputedHeight()).toBe(220); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(10); - expect(root_child0_child0_child0.getComputedTop()).toBe(10); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(220); - expect(root.getComputedHeight()).toBe(220); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(140); - expect(root_child0_child0_child0.getComputedTop()).toBe(10); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 10); + root_child0.setMargin(Edge.Top, 10); + root_child0.setMargin(Edge.Right, 10); + root_child0.setMargin(Edge.Bottom, 10); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setBorder(Edge.Left, 10); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 10); + root_child0_child0.setBorder(Edge.Bottom, 10); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(220); + expect(root.getComputedHeight()).toBe(220); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(220); + expect(root.getComputedHeight()).toBe(220); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(140); + expect(root_child0_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('absolute_layout_column_reverse_margin_border', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.ColumnReverse); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPosition(Edge.Left, 5); - root_child0.setPosition(Edge.Right, 3); - root_child0.setMargin(Edge.Left, 3); - root_child0.setMargin(Edge.Right, 4); - root_child0.setBorder(Edge.Left, 1); - root_child0.setBorder(Edge.Right, 7); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(8); - expect(root_child0.getComputedTop()).toBe(150); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(143); - expect(root_child0.getComputedTop()).toBe(150); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, 5); + root_child0.setPosition(Edge.Right, 3); + root_child0.setMargin(Edge.Left, 3); + root_child0.setMargin(Edge.Right, 4); + root_child0.setBorder(Edge.Left, 1); + root_child0.setBorder(Edge.Right, 7); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(8); + expect(root_child0.getComputedTop()).toBe(150); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(143); + expect(root_child0.getComputedTop()).toBe(150); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); }); diff --git a/javascript/tests/generated/YGAlignContentTest.test.ts b/javascript/tests/generated/YGAlignContentTest.test.ts index aecef1a641..45976eccf7 100644 --- a/javascript/tests/generated/YGAlignContentTest.test.ts +++ b/javascript/tests/generated/YGAlignContentTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<482bf432985f4cafb8a4b1f37e6d7d26>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignContentTest.html */ @@ -30,5800 +30,5224 @@ import { test('align_content_flex_start_nowrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); }); test('align_content_flex_start_wrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root_child3.setHeight(10); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root_child4.setHeight(10); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(10); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(50); - expect(root_child3.getComputedTop()).toBe(10); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(20); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(90); - expect(root_child2.getComputedTop()).toBe(10); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(40); - expect(root_child3.getComputedTop()).toBe(10); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(90); - expect(root_child4.getComputedTop()).toBe(20); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(10); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root_child4.setHeight(10); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(20); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(90); + expect(root_child4.getComputedTop()).toBe(20); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); }); test('align_content_flex_start_wrap_singleline', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); }); test('align_content_flex_start_wrapped_negative_space', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 60); - root.setBorder(Edge.Top, 60); - root.setBorder(Edge.Right, 60); - root.setBorder(Edge.Bottom, 60); - root.setWidth(320); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setJustifyContent(Justify.Center); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("80%"); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth("80%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth("80%"); - root_child0_child2.setHeight(20); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(20); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(40); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(20); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(40); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); }); test('align_content_flex_start_wrapped_negative_space_gap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 60); - root.setBorder(Edge.Top, 60); - root.setBorder(Edge.Right, 60); - root.setBorder(Edge.Bottom, 60); - root.setWidth(320); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setJustifyContent(Justify.Center); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(10); - root_child0.setGap(Gutter.Column, 10); - root_child0.setGap(Gutter.Row, 10); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("80%"); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth("80%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth("80%"); - root_child0_child2.setHeight(20); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(30); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(60); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(30); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(60); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); }); test('align_content_flex_start_without_height_on_children', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root_child3.setHeight(10); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(10); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(0); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(10); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(20); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(50); - expect(root_child2.getComputedTop()).toBe(10); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(0); - - expect(root_child3.getComputedLeft()).toBe(50); - expect(root_child3.getComputedTop()).toBe(10); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(20); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(10); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(20); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(20); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(0); }); test('align_content_flex_start_with_flex', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis("0%"); - root_child0.setWidth(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexBasis("0%"); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setFlexGrow(1); - root_child3.setFlexShrink(1); - root_child3.setFlexBasis("0%"); - root_child3.setWidth(50); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(40); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(40); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(80); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(0); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(80); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(40); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(120); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(40); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(40); - - expect(root_child2.getComputedLeft()).toBe(50); - expect(root_child2.getComputedTop()).toBe(80); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(0); - - expect(root_child3.getComputedLeft()).toBe(50); - expect(root_child3.getComputedTop()).toBe(80); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(40); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(120); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("0%"); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexBasis("0%"); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setFlexGrow(1); + root_child3.setFlexShrink(1); + root_child3.setFlexBasis("0%"); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(120); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(120); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(0); }); test('align_content_flex_end_nowrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); }); test('align_content_flex_end_wrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root_child3.setHeight(10); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root_child4.setHeight(10); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(90); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(90); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(50); - expect(root_child3.getComputedTop()).toBe(100); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(110); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(90); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(90); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(90); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(40); - expect(root_child3.getComputedTop()).toBe(100); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(90); - expect(root_child4.getComputedTop()).toBe(110); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(10); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root_child4.setHeight(10); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(90); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(90); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(110); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(90); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(90); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(90); + expect(root_child4.getComputedTop()).toBe(110); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); }); test('align_content_flex_end_wrap_singleline', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(110); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(110); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(110); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(110); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(110); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(110); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(110); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(110); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); }); test('align_content_flex_end_wrapped_negative_space', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 60); - root.setBorder(Edge.Top, 60); - root.setBorder(Edge.Right, 60); - root.setBorder(Edge.Bottom, 60); - root.setWidth(320); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setJustifyContent(Justify.Center); - root_child0.setAlignContent(Align.FlexEnd); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("80%"); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth("80%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth("80%"); - root_child0_child2.setHeight(20); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(-50); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(-30); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(-10); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(-50); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(-30); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(-10); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.FlexEnd); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(-10); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(-10); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); }); test('align_content_flex_end_wrapped_negative_space_gap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 60); - root.setBorder(Edge.Top, 60); - root.setBorder(Edge.Right, 60); - root.setBorder(Edge.Bottom, 60); - root.setWidth(320); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setJustifyContent(Justify.Center); - root_child0.setAlignContent(Align.FlexEnd); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(10); - root_child0.setGap(Gutter.Column, 10); - root_child0.setGap(Gutter.Row, 10); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("80%"); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth("80%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth("80%"); - root_child0_child2.setHeight(20); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(-70); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(-40); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(-10); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(-70); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(-40); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(-10); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.FlexEnd); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-70); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-40); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(-10); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-70); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-40); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(-10); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); }); test('align_content_center_nowrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); }); test('align_content_center_wrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root_child3.setHeight(10); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root_child4.setHeight(10); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(45); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(45); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(55); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(50); - expect(root_child3.getComputedTop()).toBe(55); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(65); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(45); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(45); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(90); - expect(root_child2.getComputedTop()).toBe(55); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(40); - expect(root_child3.getComputedTop()).toBe(55); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(90); - expect(root_child4.getComputedTop()).toBe(65); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(10); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root_child4.setHeight(10); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(45); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(45); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(65); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(45); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(45); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(90); + expect(root_child4.getComputedTop()).toBe(65); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); }); test('align_content_center_wrap_singleline', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(55); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(55); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(55); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(55); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(55); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(55); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); }); test('align_content_center_wrapped_negative_space', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 60); - root.setBorder(Edge.Top, 60); - root.setBorder(Edge.Right, 60); - root.setBorder(Edge.Bottom, 60); - root.setWidth(320); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setJustifyContent(Justify.Center); - root_child0.setAlignContent(Align.Center); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("80%"); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth("80%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth("80%"); - root_child0_child2.setHeight(20); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(-25); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(-5); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(15); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(-25); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(-5); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(15); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.Center); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-25); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-5); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(15); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-25); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-5); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(15); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); }); test('align_content_center_wrapped_negative_space_gap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 60); - root.setBorder(Edge.Top, 60); - root.setBorder(Edge.Right, 60); - root.setBorder(Edge.Bottom, 60); - root.setWidth(320); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setJustifyContent(Justify.Center); - root_child0.setAlignContent(Align.Center); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(10); - root_child0.setGap(Gutter.Column, 10); - root_child0.setGap(Gutter.Row, 10); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("80%"); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth("80%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth("80%"); - root_child0_child2.setHeight(20); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(-35); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(-5); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(25); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(-35); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(-5); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(25); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.Center); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-35); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-5); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(25); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-35); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-5); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(25); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); }); test('align_content_space_between_nowrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceBetween); - root.setPositionType(PositionType.Absolute); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); }); test('align_content_space_between_wrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceBetween); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root_child3.setHeight(10); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root_child4.setHeight(10); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(55); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(50); - expect(root_child3.getComputedTop()).toBe(55); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(110); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(90); - expect(root_child2.getComputedTop()).toBe(55); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(40); - expect(root_child3.getComputedTop()).toBe(55); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(90); - expect(root_child4.getComputedTop()).toBe(110); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(10); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root_child4.setHeight(10); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(110); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(90); + expect(root_child4.getComputedTop()).toBe(110); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); }); test('align_content_space_between_wrap_singleline', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceBetween); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); }); test('align_content_space_between_wrapped_negative_space', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 60); - root.setBorder(Edge.Top, 60); - root.setBorder(Edge.Right, 60); - root.setBorder(Edge.Bottom, 60); - root.setWidth(320); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setJustifyContent(Justify.Center); - root_child0.setAlignContent(Align.SpaceBetween); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("80%"); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth("80%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth("80%"); - root_child0_child2.setHeight(20); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(20); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(40); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(20); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(40); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceBetween); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); }); test('align_content_space_between_wrapped_negative_space_row_reverse', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 60); - root.setBorder(Edge.Top, 60); - root.setBorder(Edge.Right, 60); - root.setBorder(Edge.Bottom, 60); - root.setWidth(320); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setJustifyContent(Justify.Center); - root_child0.setAlignContent(Align.SpaceBetween); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("80%"); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth("80%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth("80%"); - root_child0_child2.setHeight(20); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(20); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(40); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(20); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(40); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceBetween); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); }); test('align_content_space_between_wrapped_negative_space_gap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 60); - root.setBorder(Edge.Top, 60); - root.setBorder(Edge.Right, 60); - root.setBorder(Edge.Bottom, 60); - root.setWidth(320); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setJustifyContent(Justify.Center); - root_child0.setAlignContent(Align.SpaceBetween); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(10); - root_child0.setGap(Gutter.Column, 10); - root_child0.setGap(Gutter.Row, 10); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("80%"); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth("80%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth("80%"); - root_child0_child2.setHeight(20); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(30); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(60); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(30); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(60); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceBetween); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); }); test('align_content_space_around_nowrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceAround); - root.setPositionType(PositionType.Absolute); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); }); test('align_content_space_around_wrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceAround); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root_child3.setHeight(10); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root_child4.setHeight(10); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(15); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(15); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(55); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(50); - expect(root_child3.getComputedTop()).toBe(55); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(95); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(15); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(15); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(90); - expect(root_child2.getComputedTop()).toBe(55); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(40); - expect(root_child3.getComputedTop()).toBe(55); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(90); - expect(root_child4.getComputedTop()).toBe(95); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(10); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root_child4.setHeight(10); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(15); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(95); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(15); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(90); + expect(root_child4.getComputedTop()).toBe(95); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); }); test('align_content_space_around_wrap_singleline', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceAround); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(55); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(55); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(55); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(55); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(55); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(55); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); }); test('align_content_space_around_wrapped_negative_space', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 60); - root.setBorder(Edge.Top, 60); - root.setBorder(Edge.Right, 60); - root.setBorder(Edge.Bottom, 60); - root.setWidth(320); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setJustifyContent(Justify.Center); - root_child0.setAlignContent(Align.SpaceAround); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("80%"); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth("80%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth("80%"); - root_child0_child2.setHeight(20); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(20); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(40); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(20); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(40); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceAround); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); }); test('align_content_space_around_wrapped_negative_space_row_reverse', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 60); - root.setBorder(Edge.Top, 60); - root.setBorder(Edge.Right, 60); - root.setBorder(Edge.Bottom, 60); - root.setWidth(320); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setJustifyContent(Justify.Center); - root_child0.setAlignContent(Align.SpaceAround); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("80%"); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth("80%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth("80%"); - root_child0_child2.setHeight(20); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(20); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(40); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(20); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(40); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceAround); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); }); test('align_content_space_around_wrapped_negative_space_gap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 60); - root.setBorder(Edge.Top, 60); - root.setBorder(Edge.Right, 60); - root.setBorder(Edge.Bottom, 60); - root.setWidth(320); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setJustifyContent(Justify.Center); - root_child0.setAlignContent(Align.SpaceAround); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(10); - root_child0.setGap(Gutter.Column, 10); - root_child0.setGap(Gutter.Row, 10); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("80%"); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth("80%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth("80%"); - root_child0_child2.setHeight(20); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(30); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(60); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(30); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(60); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceAround); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); }); test('align_content_space_evenly_nowrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceEvenly); - root.setPositionType(PositionType.Absolute); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); }); test('align_content_space_evenly_wrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceEvenly); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root_child3.setHeight(10); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root_child4.setHeight(10); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(23); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(23); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(55); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(50); - expect(root_child3.getComputedTop()).toBe(55); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(88); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(23); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(23); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(90); - expect(root_child2.getComputedTop()).toBe(55); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(40); - expect(root_child3.getComputedTop()).toBe(55); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(90); - expect(root_child4.getComputedTop()).toBe(88); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(10); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root_child4.setHeight(10); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(23); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(23); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(88); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(23); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(23); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(90); + expect(root_child4.getComputedTop()).toBe(88); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); }); test('align_content_space_evenly_wrap_singleline', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceEvenly); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(140); - root.setHeight(120); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(55); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(55); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(120); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(55); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(55); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(55); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(55); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); }); test('align_content_space_evenly_wrapped_negative_space', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 60); - root.setBorder(Edge.Top, 60); - root.setBorder(Edge.Right, 60); - root.setBorder(Edge.Bottom, 60); - root.setWidth(320); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setJustifyContent(Justify.Center); - root_child0.setAlignContent(Align.SpaceEvenly); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("80%"); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth("80%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth("80%"); - root_child0_child2.setHeight(20); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(20); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(40); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(20); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(40); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceEvenly); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); }); test('align_content_space_evenly_wrapped_negative_space_gap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 60); - root.setBorder(Edge.Top, 60); - root.setBorder(Edge.Right, 60); - root.setBorder(Edge.Bottom, 60); - root.setWidth(320); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setJustifyContent(Justify.Center); - root_child0.setAlignContent(Align.SpaceEvenly); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(10); - root_child0.setGap(Gutter.Column, 10); - root_child0.setGap(Gutter.Row, 10); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("80%"); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth("80%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth("80%"); - root_child0_child2.setHeight(20); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(30); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(60); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(60); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child1.getComputedLeft()).toBe(20); - expect(root_child0_child1.getComputedTop()).toBe(30); - expect(root_child0_child1.getComputedWidth()).toBe(160); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(60); - expect(root_child0_child2.getComputedWidth()).toBe(160); - expect(root_child0_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceEvenly); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); }); test('align_content_stretch', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(150); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(0); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(0); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(0); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(100); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(100); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(0); - - expect(root_child3.getComputedLeft()).toBe(100); - expect(root_child3.getComputedTop()).toBe(0); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(0); - - expect(root_child4.getComputedLeft()).toBe(100); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(100); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(0); }); test('align_content_stretch_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(150); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(100); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(50); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(50); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(50); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - expect(root_child3.getComputedLeft()).toBe(100); - expect(root_child3.getComputedTop()).toBe(50); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(50); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(50); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(50); }); test('align_content_stretch_row_with_children', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(150); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0_child0.setFlexBasis("0%"); - root_child0.insertChild(root_child0_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(100); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(50); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(50); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(50); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - expect(root_child3.getComputedLeft()).toBe(100); - expect(root_child3.getComputedTop()).toBe(50); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(50); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(50); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0.insertChild(root_child0_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(50); }); test('align_content_stretch_row_with_flex', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(150); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexShrink(1); - root_child1.setFlexBasis("0%"); - root_child1.setWidth(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setFlexGrow(1); - root_child3.setFlexShrink(1); - root_child3.setFlexBasis("0%"); - root_child3.setWidth(50); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(50); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(100); - expect(root_child3.getComputedTop()).toBe(0); - expect(root_child3.getComputedWidth()).toBe(0); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(100); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(100); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(50); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(50); - expect(root_child3.getComputedTop()).toBe(0); - expect(root_child3.getComputedWidth()).toBe(0); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setFlexGrow(1); + root_child3.setFlexShrink(1); + root_child3.setFlexBasis("0%"); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(0); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(100); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(0); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(100); }); test('align_content_stretch_row_with_flex_no_shrink', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(150); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexShrink(1); - root_child1.setFlexBasis("0%"); - root_child1.setWidth(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setFlexGrow(1); - root_child3.setFlexBasis("0%"); - root_child3.setWidth(50); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(50); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(100); - expect(root_child3.getComputedTop()).toBe(0); - expect(root_child3.getComputedWidth()).toBe(0); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(100); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(100); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(50); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(50); - expect(root_child3.getComputedTop()).toBe(0); - expect(root_child3.getComputedWidth()).toBe(0); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setFlexGrow(1); + root_child3.setFlexBasis("0%"); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(0); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(100); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(0); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(100); }); test('align_content_stretch_row_with_margin', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(150); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setMargin(Edge.Left, 10); - root_child1.setMargin(Edge.Top, 10); - root_child1.setMargin(Edge.Right, 10); - root_child1.setMargin(Edge.Bottom, 10); - root_child1.setWidth(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setMargin(Edge.Left, 10); - root_child3.setMargin(Edge.Top, 10); - root_child3.setMargin(Edge.Right, 10); - root_child3.setMargin(Edge.Bottom, 10); - root_child3.setWidth(50); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(40); - - expect(root_child1.getComputedLeft()).toBe(60); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(40); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(40); - - expect(root_child3.getComputedLeft()).toBe(60); - expect(root_child3.getComputedTop()).toBe(50); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(80); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(40); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(100); - expect(root_child2.getComputedTop()).toBe(40); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(40); - - expect(root_child3.getComputedLeft()).toBe(40); - expect(root_child3.getComputedTop()).toBe(50); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(100); - expect(root_child4.getComputedTop()).toBe(80); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Left, 10); + root_child1.setMargin(Edge.Top, 10); + root_child1.setMargin(Edge.Right, 10); + root_child1.setMargin(Edge.Bottom, 10); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setMargin(Edge.Left, 10); + root_child3.setMargin(Edge.Top, 10); + root_child3.setMargin(Edge.Right, 10); + root_child3.setMargin(Edge.Bottom, 10); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(60); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(100); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(20); }); test('align_content_stretch_row_with_padding', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(150); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setPadding(Edge.Left, 10); - root_child1.setPadding(Edge.Top, 10); - root_child1.setPadding(Edge.Right, 10); - root_child1.setPadding(Edge.Bottom, 10); - root_child1.setWidth(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setPadding(Edge.Left, 10); - root_child3.setPadding(Edge.Top, 10); - root_child3.setPadding(Edge.Right, 10); - root_child3.setPadding(Edge.Bottom, 10); - root_child3.setWidth(50); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(100); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(50); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(50); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(50); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - expect(root_child3.getComputedLeft()).toBe(100); - expect(root_child3.getComputedTop()).toBe(50); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(50); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(50); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPadding(Edge.Left, 10); + root_child1.setPadding(Edge.Top, 10); + root_child1.setPadding(Edge.Right, 10); + root_child1.setPadding(Edge.Bottom, 10); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setPadding(Edge.Left, 10); + root_child3.setPadding(Edge.Top, 10); + root_child3.setPadding(Edge.Right, 10); + root_child3.setPadding(Edge.Bottom, 10); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(50); }); test('align_content_stretch_row_with_single_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(150); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(100); }); test('align_content_stretch_row_with_fixed_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(150); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(60); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(80); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(60); - - expect(root_child2.getComputedLeft()).toBe(100); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(80); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(80); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(80); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(80); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(60); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(80); - - expect(root_child3.getComputedLeft()).toBe(100); - expect(root_child3.getComputedTop()).toBe(80); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(80); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(60); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(80); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(80); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(20); }); test('align_content_stretch_row_with_max_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(150); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setMaxHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(100); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(50); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(50); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(50); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - expect(root_child3.getComputedLeft()).toBe(100); - expect(root_child3.getComputedTop()).toBe(50); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(50); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(50); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setMaxHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(50); }); test('align_content_stretch_row_with_min_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(150); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setMinHeight(80); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(90); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(90); - - expect(root_child2.getComputedLeft()).toBe(100); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(90); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(90); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(90); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(90); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(90); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(90); - - expect(root_child3.getComputedLeft()).toBe(100); - expect(root_child3.getComputedTop()).toBe(90); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(10); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(90); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setMinHeight(80); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(90); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(90); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(90); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(90); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); }); test('align_content_stretch_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(150); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0_child0.setFlexBasis("0%"); - root_child0.insertChild(root_child0_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexShrink(1); - root_child1.setFlexBasis("0%"); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setHeight(50); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setHeight(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(50); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(100); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(50); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(50); - expect(root_child2.getComputedTop()).toBe(50); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - expect(root_child3.getComputedLeft()).toBe(50); - expect(root_child3.getComputedTop()).toBe(100); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(50); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(50); - expect(root_child4.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(150); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0.insertChild(root_child0_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setHeight(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setHeight(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(50); }); test('align_content_stretch_is_not_overriding_align_items', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setAlignContent(Align.Stretch); - root_child0.setAlignItems(Align.Center); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setAlignContent(Align.Stretch); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(45); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(45); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setAlignContent(Align.Stretch); + root_child0.setAlignItems(Align.Center); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(45); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(45); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); }); test('align_content_stretch_with_min_cross_axis', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(500); - root.setMinHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(400); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(400); - root_child1.setHeight(200); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(250); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(100); - expect(root_child1.getComputedTop()).toBe(250); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(500); + root.setMinHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(250); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(250); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); }); test('align_content_stretch_with_max_cross_axis', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(500); - root.setMaxHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(400); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(400); - root_child1.setHeight(200); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(200); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(100); - expect(root_child1.getComputedTop()).toBe(200); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(500); + root.setMaxHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); }); test('align_content_stretch_with_max_cross_axis_and_border_padding', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setPadding(Edge.Left, 2); - root.setPadding(Edge.Top, 2); - root.setPadding(Edge.Right, 2); - root.setPadding(Edge.Bottom, 2); - root.setBorder(Edge.Left, 5); - root.setBorder(Edge.Top, 5); - root.setBorder(Edge.Right, 5); - root.setBorder(Edge.Bottom, 5); - root.setWidth(500); - root.setMaxHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(400); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(400); - root_child1.setHeight(200); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(414); - - expect(root_child0.getComputedLeft()).toBe(7); - expect(root_child0.getComputedTop()).toBe(7); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(7); - expect(root_child1.getComputedTop()).toBe(207); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(414); - - expect(root_child0.getComputedLeft()).toBe(93); - expect(root_child0.getComputedTop()).toBe(7); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(93); - expect(root_child1.getComputedTop()).toBe(207); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setPadding(Edge.Left, 2); + root.setPadding(Edge.Top, 2); + root.setPadding(Edge.Right, 2); + root.setPadding(Edge.Bottom, 2); + root.setBorder(Edge.Left, 5); + root.setBorder(Edge.Top, 5); + root.setBorder(Edge.Right, 5); + root.setBorder(Edge.Bottom, 5); + root.setWidth(500); + root.setMaxHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(414); + + expect(root_child0.getComputedLeft()).toBe(7); + expect(root_child0.getComputedTop()).toBe(7); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(7); + expect(root_child1.getComputedTop()).toBe(207); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(414); + + expect(root_child0.getComputedLeft()).toBe(93); + expect(root_child0.getComputedTop()).toBe(7); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(93); + expect(root_child1.getComputedTop()).toBe(207); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); }); test('align_content_space_evenly_with_min_cross_axis', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceEvenly); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(500); - root.setMinHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(400); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(400); - root_child1.setHeight(200); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(33); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(267); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(33); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(100); - expect(root_child1.getComputedTop()).toBe(267); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(500); + root.setMinHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(33); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(267); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(33); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(267); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); }); test('align_content_space_evenly_with_max_cross_axis', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceEvenly); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(500); - root.setMaxHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(400); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(400); - root_child1.setHeight(200); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(200); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(100); - expect(root_child1.getComputedTop()).toBe(200); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(500); + root.setMaxHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); }); test('align_content_space_evenly_with_max_cross_axis_violated', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceEvenly); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(500); - root.setMaxHeight(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(400); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(400); - root_child1.setHeight(200); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(200); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(100); - expect(root_child1.getComputedTop()).toBe(200); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(500); + root.setMaxHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); }); test('align_content_space_evenly_with_max_cross_axis_violated_padding_and_border', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceEvenly); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setPadding(Edge.Left, 2); - root.setPadding(Edge.Top, 2); - root.setPadding(Edge.Right, 2); - root.setPadding(Edge.Bottom, 2); - root.setBorder(Edge.Left, 5); - root.setBorder(Edge.Top, 5); - root.setBorder(Edge.Right, 5); - root.setBorder(Edge.Bottom, 5); - root.setWidth(500); - root.setMaxHeight(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(400); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(400); - root_child1.setHeight(200); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(7); - expect(root_child0.getComputedTop()).toBe(7); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(7); - expect(root_child1.getComputedTop()).toBe(207); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(93); - expect(root_child0.getComputedTop()).toBe(7); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(93); - expect(root_child1.getComputedTop()).toBe(207); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setPadding(Edge.Left, 2); + root.setPadding(Edge.Top, 2); + root.setPadding(Edge.Right, 2); + root.setPadding(Edge.Bottom, 2); + root.setBorder(Edge.Left, 5); + root.setBorder(Edge.Top, 5); + root.setBorder(Edge.Right, 5); + root.setBorder(Edge.Bottom, 5); + root.setWidth(500); + root.setMaxHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(7); + expect(root_child0.getComputedTop()).toBe(7); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(7); + expect(root_child1.getComputedTop()).toBe(207); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(93); + expect(root_child0.getComputedTop()).toBe(7); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(93); + expect(root_child1.getComputedTop()).toBe(207); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); }); test('align_content_space_around_and_align_items_flex_end_with_flex_wrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceAround); - root.setAlignItems(Align.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(300); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(150); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(120); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(120); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(88); - expect(root_child0.getComputedWidth()).toBe(150); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(150); - expect(root_child1.getComputedTop()).toBe(38); - expect(root_child1.getComputedWidth()).toBe(120); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(213); - expect(root_child2.getComputedWidth()).toBe(120); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(88); - expect(root_child0.getComputedWidth()).toBe(150); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(38); - expect(root_child1.getComputedWidth()).toBe(120); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(180); - expect(root_child2.getComputedTop()).toBe(213); - expect(root_child2.getComputedWidth()).toBe(120); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(150); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(120); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(120); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(88); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(88); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); }); test('align_content_space_around_and_align_items_center_with_flex_wrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceAround); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(300); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(150); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(120); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(120); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(63); - expect(root_child0.getComputedWidth()).toBe(150); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(150); - expect(root_child1.getComputedTop()).toBe(38); - expect(root_child1.getComputedWidth()).toBe(120); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(213); - expect(root_child2.getComputedWidth()).toBe(120); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(63); - expect(root_child0.getComputedWidth()).toBe(150); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(38); - expect(root_child1.getComputedWidth()).toBe(120); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(180); - expect(root_child2.getComputedTop()).toBe(213); - expect(root_child2.getComputedWidth()).toBe(120); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(150); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(120); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(120); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(63); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(63); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); }); test('align_content_space_around_and_align_items_flex_start_with_flex_wrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceAround); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(300); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(150); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(120); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(120); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(38); - expect(root_child0.getComputedWidth()).toBe(150); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(150); - expect(root_child1.getComputedTop()).toBe(38); - expect(root_child1.getComputedWidth()).toBe(120); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(213); - expect(root_child2.getComputedWidth()).toBe(120); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(38); - expect(root_child0.getComputedWidth()).toBe(150); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(38); - expect(root_child1.getComputedWidth()).toBe(120); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(180); - expect(root_child2.getComputedTop()).toBe(213); - expect(root_child2.getComputedWidth()).toBe(120); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(150); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(120); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(120); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(38); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(38); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); }); test('align_content_flex_start_stretch_doesnt_influence_line_box_dim', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 20); - root.setPadding(Edge.Top, 20); - root.setPadding(Edge.Right, 20); - root.setPadding(Edge.Bottom, 20); - root.setWidth(400); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Right, 20); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexDirection(FlexDirection.Row); - root_child1.setFlexWrap(Wrap.Wrap); - root_child1.setFlexGrow(1); - root_child1.setFlexShrink(1); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setMargin(Edge.Right, 20); - root_child1_child0.setWidth(30); - root_child1_child0.setHeight(30); - root_child1.insertChild(root_child1_child0, 0); - - const root_child1_child1 = Yoga.Node.create(config); - root_child1_child1.setMargin(Edge.Right, 20); - root_child1_child1.setWidth(30); - root_child1_child1.setHeight(30); - root_child1.insertChild(root_child1_child1, 1); - - const root_child1_child2 = Yoga.Node.create(config); - root_child1_child2.setMargin(Edge.Right, 20); - root_child1_child2.setWidth(30); - root_child1_child2.setHeight(30); - root_child1.insertChild(root_child1_child2, 2); - - const root_child1_child3 = Yoga.Node.create(config); - root_child1_child3.setMargin(Edge.Right, 20); - root_child1_child3.setWidth(30); - root_child1_child3.setHeight(30); - root_child1.insertChild(root_child1_child3, 3); - - const root_child1_child4 = Yoga.Node.create(config); - root_child1_child4.setMargin(Edge.Right, 20); - root_child1_child4.setWidth(30); - root_child1_child4.setHeight(30); - root_child1.insertChild(root_child1_child4, 4); - - const root_child2 = Yoga.Node.create(config); - root_child2.setMargin(Edge.Left, 20); - root_child2.setWidth(50); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(140); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(140); - expect(root_child1.getComputedTop()).toBe(20); - expect(root_child1.getComputedWidth()).toBe(170); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(30); - expect(root_child1_child0.getComputedHeight()).toBe(30); - - expect(root_child1_child1.getComputedLeft()).toBe(50); - expect(root_child1_child1.getComputedTop()).toBe(0); - expect(root_child1_child1.getComputedWidth()).toBe(30); - expect(root_child1_child1.getComputedHeight()).toBe(30); - - expect(root_child1_child2.getComputedLeft()).toBe(100); - expect(root_child1_child2.getComputedTop()).toBe(0); - expect(root_child1_child2.getComputedWidth()).toBe(30); - expect(root_child1_child2.getComputedHeight()).toBe(30); - - expect(root_child1_child3.getComputedLeft()).toBe(0); - expect(root_child1_child3.getComputedTop()).toBe(30); - expect(root_child1_child3.getComputedWidth()).toBe(30); - expect(root_child1_child3.getComputedHeight()).toBe(30); - - expect(root_child1_child4.getComputedLeft()).toBe(50); - expect(root_child1_child4.getComputedTop()).toBe(30); - expect(root_child1_child4.getComputedWidth()).toBe(30); - expect(root_child1_child4.getComputedHeight()).toBe(30); - - expect(root_child2.getComputedLeft()).toBe(330); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(140); - - expect(root_child0.getComputedLeft()).toBe(260); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(90); - expect(root_child1.getComputedTop()).toBe(20); - expect(root_child1.getComputedWidth()).toBe(170); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child1_child0.getComputedLeft()).toBe(120); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(30); - expect(root_child1_child0.getComputedHeight()).toBe(30); - - expect(root_child1_child1.getComputedLeft()).toBe(70); - expect(root_child1_child1.getComputedTop()).toBe(0); - expect(root_child1_child1.getComputedWidth()).toBe(30); - expect(root_child1_child1.getComputedHeight()).toBe(30); - - expect(root_child1_child2.getComputedLeft()).toBe(20); - expect(root_child1_child2.getComputedTop()).toBe(0); - expect(root_child1_child2.getComputedWidth()).toBe(30); - expect(root_child1_child2.getComputedHeight()).toBe(30); - - expect(root_child1_child3.getComputedLeft()).toBe(120); - expect(root_child1_child3.getComputedTop()).toBe(30); - expect(root_child1_child3.getComputedWidth()).toBe(30); - expect(root_child1_child3.getComputedHeight()).toBe(30); - - expect(root_child1_child4.getComputedLeft()).toBe(70); - expect(root_child1_child4.getComputedTop()).toBe(30); - expect(root_child1_child4.getComputedWidth()).toBe(30); - expect(root_child1_child4.getComputedHeight()).toBe(30); - - expect(root_child2.getComputedLeft()).toBe(40); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 20); + root.setPadding(Edge.Top, 20); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 20); + root.setWidth(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 20); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(FlexDirection.Row); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setMargin(Edge.Right, 20); + root_child1_child0.setWidth(30); + root_child1_child0.setHeight(30); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setMargin(Edge.Right, 20); + root_child1_child1.setWidth(30); + root_child1_child1.setHeight(30); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setMargin(Edge.Right, 20); + root_child1_child2.setWidth(30); + root_child1_child2.setHeight(30); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setMargin(Edge.Right, 20); + root_child1_child3.setWidth(30); + root_child1_child3.setHeight(30); + root_child1.insertChild(root_child1_child3, 3); + + const root_child1_child4 = Yoga.Node.create(config); + root_child1_child4.setMargin(Edge.Right, 20); + root_child1_child4.setWidth(30); + root_child1_child4.setHeight(30); + root_child1.insertChild(root_child1_child4, 4); + + const root_child2 = Yoga.Node.create(config); + root_child2.setMargin(Edge.Left, 20); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(140); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(140); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(50); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(100); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(0); + expect(root_child1_child3.getComputedTop()).toBe(30); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(50); + expect(root_child1_child4.getComputedTop()).toBe(30); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(330); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(140); + + expect(root_child0.getComputedLeft()).toBe(260); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(120); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(70); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(20); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(120); + expect(root_child1_child3.getComputedTop()).toBe(30); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(70); + expect(root_child1_child4.getComputedTop()).toBe(30); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); }); test('align_content_stretch_stretch_does_influence_line_box_dim', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 20); - root.setPadding(Edge.Top, 20); - root.setPadding(Edge.Right, 20); - root.setPadding(Edge.Bottom, 20); - root.setWidth(400); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Right, 20); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexDirection(FlexDirection.Row); - root_child1.setAlignContent(Align.Stretch); - root_child1.setFlexWrap(Wrap.Wrap); - root_child1.setFlexGrow(1); - root_child1.setFlexShrink(1); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setMargin(Edge.Right, 20); - root_child1_child0.setWidth(30); - root_child1_child0.setHeight(30); - root_child1.insertChild(root_child1_child0, 0); - - const root_child1_child1 = Yoga.Node.create(config); - root_child1_child1.setMargin(Edge.Right, 20); - root_child1_child1.setWidth(30); - root_child1_child1.setHeight(30); - root_child1.insertChild(root_child1_child1, 1); - - const root_child1_child2 = Yoga.Node.create(config); - root_child1_child2.setMargin(Edge.Right, 20); - root_child1_child2.setWidth(30); - root_child1_child2.setHeight(30); - root_child1.insertChild(root_child1_child2, 2); - - const root_child1_child3 = Yoga.Node.create(config); - root_child1_child3.setMargin(Edge.Right, 20); - root_child1_child3.setWidth(30); - root_child1_child3.setHeight(30); - root_child1.insertChild(root_child1_child3, 3); - - const root_child1_child4 = Yoga.Node.create(config); - root_child1_child4.setMargin(Edge.Right, 20); - root_child1_child4.setWidth(30); - root_child1_child4.setHeight(30); - root_child1.insertChild(root_child1_child4, 4); - - const root_child2 = Yoga.Node.create(config); - root_child2.setMargin(Edge.Left, 20); - root_child2.setWidth(50); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(140); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(140); - expect(root_child1.getComputedTop()).toBe(20); - expect(root_child1.getComputedWidth()).toBe(170); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(30); - expect(root_child1_child0.getComputedHeight()).toBe(30); - - expect(root_child1_child1.getComputedLeft()).toBe(50); - expect(root_child1_child1.getComputedTop()).toBe(0); - expect(root_child1_child1.getComputedWidth()).toBe(30); - expect(root_child1_child1.getComputedHeight()).toBe(30); - - expect(root_child1_child2.getComputedLeft()).toBe(100); - expect(root_child1_child2.getComputedTop()).toBe(0); - expect(root_child1_child2.getComputedWidth()).toBe(30); - expect(root_child1_child2.getComputedHeight()).toBe(30); - - expect(root_child1_child3.getComputedLeft()).toBe(0); - expect(root_child1_child3.getComputedTop()).toBe(50); - expect(root_child1_child3.getComputedWidth()).toBe(30); - expect(root_child1_child3.getComputedHeight()).toBe(30); - - expect(root_child1_child4.getComputedLeft()).toBe(50); - expect(root_child1_child4.getComputedTop()).toBe(50); - expect(root_child1_child4.getComputedWidth()).toBe(30); - expect(root_child1_child4.getComputedHeight()).toBe(30); - - expect(root_child2.getComputedLeft()).toBe(330); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(140); - - expect(root_child0.getComputedLeft()).toBe(260); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(90); - expect(root_child1.getComputedTop()).toBe(20); - expect(root_child1.getComputedWidth()).toBe(170); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child1_child0.getComputedLeft()).toBe(120); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(30); - expect(root_child1_child0.getComputedHeight()).toBe(30); - - expect(root_child1_child1.getComputedLeft()).toBe(70); - expect(root_child1_child1.getComputedTop()).toBe(0); - expect(root_child1_child1.getComputedWidth()).toBe(30); - expect(root_child1_child1.getComputedHeight()).toBe(30); - - expect(root_child1_child2.getComputedLeft()).toBe(20); - expect(root_child1_child2.getComputedTop()).toBe(0); - expect(root_child1_child2.getComputedWidth()).toBe(30); - expect(root_child1_child2.getComputedHeight()).toBe(30); - - expect(root_child1_child3.getComputedLeft()).toBe(120); - expect(root_child1_child3.getComputedTop()).toBe(50); - expect(root_child1_child3.getComputedWidth()).toBe(30); - expect(root_child1_child3.getComputedHeight()).toBe(30); - - expect(root_child1_child4.getComputedLeft()).toBe(70); - expect(root_child1_child4.getComputedTop()).toBe(50); - expect(root_child1_child4.getComputedWidth()).toBe(30); - expect(root_child1_child4.getComputedHeight()).toBe(30); - - expect(root_child2.getComputedLeft()).toBe(40); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 20); + root.setPadding(Edge.Top, 20); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 20); + root.setWidth(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 20); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(FlexDirection.Row); + root_child1.setAlignContent(Align.Stretch); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setMargin(Edge.Right, 20); + root_child1_child0.setWidth(30); + root_child1_child0.setHeight(30); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setMargin(Edge.Right, 20); + root_child1_child1.setWidth(30); + root_child1_child1.setHeight(30); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setMargin(Edge.Right, 20); + root_child1_child2.setWidth(30); + root_child1_child2.setHeight(30); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setMargin(Edge.Right, 20); + root_child1_child3.setWidth(30); + root_child1_child3.setHeight(30); + root_child1.insertChild(root_child1_child3, 3); + + const root_child1_child4 = Yoga.Node.create(config); + root_child1_child4.setMargin(Edge.Right, 20); + root_child1_child4.setWidth(30); + root_child1_child4.setHeight(30); + root_child1.insertChild(root_child1_child4, 4); + + const root_child2 = Yoga.Node.create(config); + root_child2.setMargin(Edge.Left, 20); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(140); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(140); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(50); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(100); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(0); + expect(root_child1_child3.getComputedTop()).toBe(50); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(50); + expect(root_child1_child4.getComputedTop()).toBe(50); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(330); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(140); + + expect(root_child0.getComputedLeft()).toBe(260); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(120); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(70); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(20); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(120); + expect(root_child1_child3.getComputedTop()).toBe(50); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(70); + expect(root_child1_child4.getComputedTop()).toBe(50); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); }); test('align_content_space_evenly_stretch_does_influence_line_box_dim', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 20); - root.setPadding(Edge.Top, 20); - root.setPadding(Edge.Right, 20); - root.setPadding(Edge.Bottom, 20); - root.setWidth(400); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Right, 20); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexDirection(FlexDirection.Row); - root_child1.setAlignContent(Align.Stretch); - root_child1.setFlexWrap(Wrap.Wrap); - root_child1.setFlexGrow(1); - root_child1.setFlexShrink(1); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setMargin(Edge.Right, 20); - root_child1_child0.setWidth(30); - root_child1_child0.setHeight(30); - root_child1.insertChild(root_child1_child0, 0); - - const root_child1_child1 = Yoga.Node.create(config); - root_child1_child1.setMargin(Edge.Right, 20); - root_child1_child1.setWidth(30); - root_child1_child1.setHeight(30); - root_child1.insertChild(root_child1_child1, 1); - - const root_child1_child2 = Yoga.Node.create(config); - root_child1_child2.setMargin(Edge.Right, 20); - root_child1_child2.setWidth(30); - root_child1_child2.setHeight(30); - root_child1.insertChild(root_child1_child2, 2); - - const root_child1_child3 = Yoga.Node.create(config); - root_child1_child3.setMargin(Edge.Right, 20); - root_child1_child3.setWidth(30); - root_child1_child3.setHeight(30); - root_child1.insertChild(root_child1_child3, 3); - - const root_child1_child4 = Yoga.Node.create(config); - root_child1_child4.setMargin(Edge.Right, 20); - root_child1_child4.setWidth(30); - root_child1_child4.setHeight(30); - root_child1.insertChild(root_child1_child4, 4); - - const root_child2 = Yoga.Node.create(config); - root_child2.setMargin(Edge.Left, 20); - root_child2.setWidth(50); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(140); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(140); - expect(root_child1.getComputedTop()).toBe(20); - expect(root_child1.getComputedWidth()).toBe(170); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(30); - expect(root_child1_child0.getComputedHeight()).toBe(30); - - expect(root_child1_child1.getComputedLeft()).toBe(50); - expect(root_child1_child1.getComputedTop()).toBe(0); - expect(root_child1_child1.getComputedWidth()).toBe(30); - expect(root_child1_child1.getComputedHeight()).toBe(30); - - expect(root_child1_child2.getComputedLeft()).toBe(100); - expect(root_child1_child2.getComputedTop()).toBe(0); - expect(root_child1_child2.getComputedWidth()).toBe(30); - expect(root_child1_child2.getComputedHeight()).toBe(30); - - expect(root_child1_child3.getComputedLeft()).toBe(0); - expect(root_child1_child3.getComputedTop()).toBe(50); - expect(root_child1_child3.getComputedWidth()).toBe(30); - expect(root_child1_child3.getComputedHeight()).toBe(30); - - expect(root_child1_child4.getComputedLeft()).toBe(50); - expect(root_child1_child4.getComputedTop()).toBe(50); - expect(root_child1_child4.getComputedWidth()).toBe(30); - expect(root_child1_child4.getComputedHeight()).toBe(30); - - expect(root_child2.getComputedLeft()).toBe(330); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(140); - - expect(root_child0.getComputedLeft()).toBe(260); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(90); - expect(root_child1.getComputedTop()).toBe(20); - expect(root_child1.getComputedWidth()).toBe(170); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child1_child0.getComputedLeft()).toBe(120); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(30); - expect(root_child1_child0.getComputedHeight()).toBe(30); - - expect(root_child1_child1.getComputedLeft()).toBe(70); - expect(root_child1_child1.getComputedTop()).toBe(0); - expect(root_child1_child1.getComputedWidth()).toBe(30); - expect(root_child1_child1.getComputedHeight()).toBe(30); - - expect(root_child1_child2.getComputedLeft()).toBe(20); - expect(root_child1_child2.getComputedTop()).toBe(0); - expect(root_child1_child2.getComputedWidth()).toBe(30); - expect(root_child1_child2.getComputedHeight()).toBe(30); - - expect(root_child1_child3.getComputedLeft()).toBe(120); - expect(root_child1_child3.getComputedTop()).toBe(50); - expect(root_child1_child3.getComputedWidth()).toBe(30); - expect(root_child1_child3.getComputedHeight()).toBe(30); - - expect(root_child1_child4.getComputedLeft()).toBe(70); - expect(root_child1_child4.getComputedTop()).toBe(50); - expect(root_child1_child4.getComputedWidth()).toBe(30); - expect(root_child1_child4.getComputedHeight()).toBe(30); - - expect(root_child2.getComputedLeft()).toBe(40); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 20); + root.setPadding(Edge.Top, 20); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 20); + root.setWidth(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 20); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(FlexDirection.Row); + root_child1.setAlignContent(Align.Stretch); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setMargin(Edge.Right, 20); + root_child1_child0.setWidth(30); + root_child1_child0.setHeight(30); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setMargin(Edge.Right, 20); + root_child1_child1.setWidth(30); + root_child1_child1.setHeight(30); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setMargin(Edge.Right, 20); + root_child1_child2.setWidth(30); + root_child1_child2.setHeight(30); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setMargin(Edge.Right, 20); + root_child1_child3.setWidth(30); + root_child1_child3.setHeight(30); + root_child1.insertChild(root_child1_child3, 3); + + const root_child1_child4 = Yoga.Node.create(config); + root_child1_child4.setMargin(Edge.Right, 20); + root_child1_child4.setWidth(30); + root_child1_child4.setHeight(30); + root_child1.insertChild(root_child1_child4, 4); + + const root_child2 = Yoga.Node.create(config); + root_child2.setMargin(Edge.Left, 20); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(140); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(140); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(50); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(100); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(0); + expect(root_child1_child3.getComputedTop()).toBe(50); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(50); + expect(root_child1_child4.getComputedTop()).toBe(50); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(330); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(140); + + expect(root_child0.getComputedLeft()).toBe(260); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(120); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(70); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(20); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(120); + expect(root_child1_child3.getComputedTop()).toBe(50); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(70); + expect(root_child1_child4.getComputedTop()).toBe(50); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); }); test('align_content_stretch_and_align_items_flex_end_with_flex_wrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setAlignItems(Align.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(300); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignSelf(Align.FlexStart); - root_child0.setWidth(150); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(120); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(120); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(150); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(150); - expect(root_child1.getComputedTop()).toBe(75); - expect(root_child1.getComputedWidth()).toBe(120); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(250); - expect(root_child2.getComputedWidth()).toBe(120); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(150); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(75); - expect(root_child1.getComputedWidth()).toBe(120); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(180); - expect(root_child2.getComputedTop()).toBe(250); - expect(root_child2.getComputedWidth()).toBe(120); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexStart); + root_child0.setWidth(150); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(120); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(120); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(250); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(250); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); }); test('align_content_stretch_and_align_items_flex_start_with_flex_wrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(300); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignSelf(Align.FlexEnd); - root_child0.setWidth(150); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(120); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(120); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(125); - expect(root_child0.getComputedWidth()).toBe(150); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(150); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(120); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(175); - expect(root_child2.getComputedWidth()).toBe(120); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(125); - expect(root_child0.getComputedWidth()).toBe(150); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(120); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(180); - expect(root_child2.getComputedTop()).toBe(175); - expect(root_child2.getComputedWidth()).toBe(120); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexEnd); + root_child0.setWidth(150); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(120); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(120); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(125); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(175); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(125); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(175); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); }); test('align_content_stretch_and_align_items_center_with_flex_wrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(300); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignSelf(Align.FlexEnd); - root_child0.setWidth(150); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(120); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(120); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(125); - expect(root_child0.getComputedWidth()).toBe(150); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(150); - expect(root_child1.getComputedTop()).toBe(38); - expect(root_child1.getComputedWidth()).toBe(120); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(213); - expect(root_child2.getComputedWidth()).toBe(120); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(125); - expect(root_child0.getComputedWidth()).toBe(150); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(38); - expect(root_child1.getComputedWidth()).toBe(120); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(180); - expect(root_child2.getComputedTop()).toBe(213); - expect(root_child2.getComputedWidth()).toBe(120); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexEnd); + root_child0.setWidth(150); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(120); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(120); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(125); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(125); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); }); test('align_content_stretch_and_align_items_stretch_with_flex_wrap', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(300); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignSelf(Align.FlexEnd); - root_child0.setWidth(150); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(120); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(120); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(125); - expect(root_child0.getComputedWidth()).toBe(150); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(150); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(120); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(175); - expect(root_child2.getComputedWidth()).toBe(120); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(125); - expect(root_child0.getComputedWidth()).toBe(150); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(120); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(180); - expect(root_child2.getComputedTop()).toBe(175); - expect(root_child2.getComputedWidth()).toBe(120); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexEnd); + root_child0.setWidth(150); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(120); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(120); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(125); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(175); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(125); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(175); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); }); diff --git a/javascript/tests/generated/YGAlignItemsTest.test.ts b/javascript/tests/generated/YGAlignItemsTest.test.ts index ae4dc63585..642fb5c59c 100644 --- a/javascript/tests/generated/YGAlignItemsTest.test.ts +++ b/javascript/tests/generated/YGAlignItemsTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<803460e1a13802de47a199dc66e0ace2>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html */ @@ -30,2500 +30,2221 @@ import { test('align_items_stretch', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); }); test('align_items_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(45); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(45); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('align_items_flex_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('align_items_flex_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('align_baseline', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Baseline); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(30); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(30); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); }); test('align_baseline_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Baseline); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setWidth(50); - root_child1_child0.setHeight(10); - root_child1.insertChild(root_child1_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1.insertChild(root_child1_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); }); test('align_baseline_child_multiline', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Baseline); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(60); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexDirection(FlexDirection.Row); - root_child1.setFlexWrap(Wrap.Wrap); - root_child1.setWidth(50); - root_child1.setHeight(25); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setWidth(25); - root_child1_child0.setHeight(20); - root_child1.insertChild(root_child1_child0, 0); - - const root_child1_child1 = Yoga.Node.create(config); - root_child1_child1.setWidth(25); - root_child1_child1.setHeight(10); - root_child1.insertChild(root_child1_child1, 1); - - const root_child1_child2 = Yoga.Node.create(config); - root_child1_child2.setWidth(25); - root_child1_child2.setHeight(20); - root_child1.insertChild(root_child1_child2, 2); - - const root_child1_child3 = Yoga.Node.create(config); - root_child1_child3.setWidth(25); - root_child1_child3.setHeight(10); - root_child1.insertChild(root_child1_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(60); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(25); - expect(root_child1_child0.getComputedHeight()).toBe(20); - - expect(root_child1_child1.getComputedLeft()).toBe(25); - expect(root_child1_child1.getComputedTop()).toBe(0); - expect(root_child1_child1.getComputedWidth()).toBe(25); - expect(root_child1_child1.getComputedHeight()).toBe(10); - - expect(root_child1_child2.getComputedLeft()).toBe(0); - expect(root_child1_child2.getComputedTop()).toBe(20); - expect(root_child1_child2.getComputedWidth()).toBe(25); - expect(root_child1_child2.getComputedHeight()).toBe(20); - - expect(root_child1_child3.getComputedLeft()).toBe(25); - expect(root_child1_child3.getComputedTop()).toBe(20); - expect(root_child1_child3.getComputedWidth()).toBe(25); - expect(root_child1_child3.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(60); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child1_child0.getComputedLeft()).toBe(25); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(25); - expect(root_child1_child0.getComputedHeight()).toBe(20); - - expect(root_child1_child1.getComputedLeft()).toBe(0); - expect(root_child1_child1.getComputedTop()).toBe(0); - expect(root_child1_child1.getComputedWidth()).toBe(25); - expect(root_child1_child1.getComputedHeight()).toBe(10); - - expect(root_child1_child2.getComputedLeft()).toBe(25); - expect(root_child1_child2.getComputedTop()).toBe(20); - expect(root_child1_child2.getComputedWidth()).toBe(25); - expect(root_child1_child2.getComputedHeight()).toBe(20); - - expect(root_child1_child3.getComputedLeft()).toBe(0); - expect(root_child1_child3.getComputedTop()).toBe(20); - expect(root_child1_child3.getComputedWidth()).toBe(25); - expect(root_child1_child3.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(FlexDirection.Row); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setWidth(50); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(25); + root_child1_child0.setHeight(20); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setWidth(25); + root_child1_child1.setHeight(10); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setWidth(25); + root_child1_child2.setHeight(20); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setWidth(25); + root_child1_child3.setHeight(10); + root_child1.insertChild(root_child1_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child1_child1.getComputedLeft()).toBe(25); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(25); + expect(root_child1_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child2.getComputedLeft()).toBe(0); + expect(root_child1_child2.getComputedTop()).toBe(20); + expect(root_child1_child2.getComputedWidth()).toBe(25); + expect(root_child1_child2.getComputedHeight()).toBe(20); + + expect(root_child1_child3.getComputedLeft()).toBe(25); + expect(root_child1_child3.getComputedTop()).toBe(20); + expect(root_child1_child3.getComputedWidth()).toBe(25); + expect(root_child1_child3.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child1_child0.getComputedLeft()).toBe(25); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child1_child1.getComputedLeft()).toBe(0); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(25); + expect(root_child1_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child2.getComputedLeft()).toBe(25); + expect(root_child1_child2.getComputedTop()).toBe(20); + expect(root_child1_child2.getComputedWidth()).toBe(25); + expect(root_child1_child2.getComputedHeight()).toBe(20); + + expect(root_child1_child3.getComputedLeft()).toBe(0); + expect(root_child1_child3.getComputedTop()).toBe(20); + expect(root_child1_child3.getComputedWidth()).toBe(25); + expect(root_child1_child3.getComputedHeight()).toBe(10); }); test('align_baseline_child_multiline_override', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Baseline); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(60); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexDirection(FlexDirection.Row); - root_child1.setFlexWrap(Wrap.Wrap); - root_child1.setWidth(50); - root_child1.setHeight(25); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setWidth(25); - root_child1_child0.setHeight(20); - root_child1.insertChild(root_child1_child0, 0); - - const root_child1_child1 = Yoga.Node.create(config); - root_child1_child1.setAlignSelf(Align.Baseline); - root_child1_child1.setWidth(25); - root_child1_child1.setHeight(10); - root_child1.insertChild(root_child1_child1, 1); - - const root_child1_child2 = Yoga.Node.create(config); - root_child1_child2.setWidth(25); - root_child1_child2.setHeight(20); - root_child1.insertChild(root_child1_child2, 2); - - const root_child1_child3 = Yoga.Node.create(config); - root_child1_child3.setAlignSelf(Align.Baseline); - root_child1_child3.setWidth(25); - root_child1_child3.setHeight(10); - root_child1.insertChild(root_child1_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(60); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(25); - expect(root_child1_child0.getComputedHeight()).toBe(20); - - expect(root_child1_child1.getComputedLeft()).toBe(25); - expect(root_child1_child1.getComputedTop()).toBe(0); - expect(root_child1_child1.getComputedWidth()).toBe(25); - expect(root_child1_child1.getComputedHeight()).toBe(10); - - expect(root_child1_child2.getComputedLeft()).toBe(0); - expect(root_child1_child2.getComputedTop()).toBe(20); - expect(root_child1_child2.getComputedWidth()).toBe(25); - expect(root_child1_child2.getComputedHeight()).toBe(20); - - expect(root_child1_child3.getComputedLeft()).toBe(25); - expect(root_child1_child3.getComputedTop()).toBe(20); - expect(root_child1_child3.getComputedWidth()).toBe(25); - expect(root_child1_child3.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(60); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child1_child0.getComputedLeft()).toBe(25); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(25); - expect(root_child1_child0.getComputedHeight()).toBe(20); - - expect(root_child1_child1.getComputedLeft()).toBe(0); - expect(root_child1_child1.getComputedTop()).toBe(0); - expect(root_child1_child1.getComputedWidth()).toBe(25); - expect(root_child1_child1.getComputedHeight()).toBe(10); - - expect(root_child1_child2.getComputedLeft()).toBe(25); - expect(root_child1_child2.getComputedTop()).toBe(20); - expect(root_child1_child2.getComputedWidth()).toBe(25); - expect(root_child1_child2.getComputedHeight()).toBe(20); - - expect(root_child1_child3.getComputedLeft()).toBe(0); - expect(root_child1_child3.getComputedTop()).toBe(20); - expect(root_child1_child3.getComputedWidth()).toBe(25); - expect(root_child1_child3.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(FlexDirection.Row); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setWidth(50); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(25); + root_child1_child0.setHeight(20); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setAlignSelf(Align.Baseline); + root_child1_child1.setWidth(25); + root_child1_child1.setHeight(10); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setWidth(25); + root_child1_child2.setHeight(20); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setAlignSelf(Align.Baseline); + root_child1_child3.setWidth(25); + root_child1_child3.setHeight(10); + root_child1.insertChild(root_child1_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child1_child1.getComputedLeft()).toBe(25); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(25); + expect(root_child1_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child2.getComputedLeft()).toBe(0); + expect(root_child1_child2.getComputedTop()).toBe(20); + expect(root_child1_child2.getComputedWidth()).toBe(25); + expect(root_child1_child2.getComputedHeight()).toBe(20); + + expect(root_child1_child3.getComputedLeft()).toBe(25); + expect(root_child1_child3.getComputedTop()).toBe(20); + expect(root_child1_child3.getComputedWidth()).toBe(25); + expect(root_child1_child3.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child1_child0.getComputedLeft()).toBe(25); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child1_child1.getComputedLeft()).toBe(0); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(25); + expect(root_child1_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child2.getComputedLeft()).toBe(25); + expect(root_child1_child2.getComputedTop()).toBe(20); + expect(root_child1_child2.getComputedWidth()).toBe(25); + expect(root_child1_child2.getComputedHeight()).toBe(20); + + expect(root_child1_child3.getComputedLeft()).toBe(0); + expect(root_child1_child3.getComputedTop()).toBe(20); + expect(root_child1_child3.getComputedWidth()).toBe(25); + expect(root_child1_child3.getComputedHeight()).toBe(10); }); test('align_baseline_child_multiline_no_override_on_secondline', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Baseline); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(60); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexDirection(FlexDirection.Row); - root_child1.setFlexWrap(Wrap.Wrap); - root_child1.setWidth(50); - root_child1.setHeight(25); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setWidth(25); - root_child1_child0.setHeight(20); - root_child1.insertChild(root_child1_child0, 0); - - const root_child1_child1 = Yoga.Node.create(config); - root_child1_child1.setWidth(25); - root_child1_child1.setHeight(10); - root_child1.insertChild(root_child1_child1, 1); - - const root_child1_child2 = Yoga.Node.create(config); - root_child1_child2.setWidth(25); - root_child1_child2.setHeight(20); - root_child1.insertChild(root_child1_child2, 2); - - const root_child1_child3 = Yoga.Node.create(config); - root_child1_child3.setAlignSelf(Align.Baseline); - root_child1_child3.setWidth(25); - root_child1_child3.setHeight(10); - root_child1.insertChild(root_child1_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(60); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(25); - expect(root_child1_child0.getComputedHeight()).toBe(20); - - expect(root_child1_child1.getComputedLeft()).toBe(25); - expect(root_child1_child1.getComputedTop()).toBe(0); - expect(root_child1_child1.getComputedWidth()).toBe(25); - expect(root_child1_child1.getComputedHeight()).toBe(10); - - expect(root_child1_child2.getComputedLeft()).toBe(0); - expect(root_child1_child2.getComputedTop()).toBe(20); - expect(root_child1_child2.getComputedWidth()).toBe(25); - expect(root_child1_child2.getComputedHeight()).toBe(20); - - expect(root_child1_child3.getComputedLeft()).toBe(25); - expect(root_child1_child3.getComputedTop()).toBe(20); - expect(root_child1_child3.getComputedWidth()).toBe(25); - expect(root_child1_child3.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(60); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child1_child0.getComputedLeft()).toBe(25); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(25); - expect(root_child1_child0.getComputedHeight()).toBe(20); - - expect(root_child1_child1.getComputedLeft()).toBe(0); - expect(root_child1_child1.getComputedTop()).toBe(0); - expect(root_child1_child1.getComputedWidth()).toBe(25); - expect(root_child1_child1.getComputedHeight()).toBe(10); - - expect(root_child1_child2.getComputedLeft()).toBe(25); - expect(root_child1_child2.getComputedTop()).toBe(20); - expect(root_child1_child2.getComputedWidth()).toBe(25); - expect(root_child1_child2.getComputedHeight()).toBe(20); - - expect(root_child1_child3.getComputedLeft()).toBe(0); - expect(root_child1_child3.getComputedTop()).toBe(20); - expect(root_child1_child3.getComputedWidth()).toBe(25); - expect(root_child1_child3.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(FlexDirection.Row); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setWidth(50); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(25); + root_child1_child0.setHeight(20); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setWidth(25); + root_child1_child1.setHeight(10); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setWidth(25); + root_child1_child2.setHeight(20); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setAlignSelf(Align.Baseline); + root_child1_child3.setWidth(25); + root_child1_child3.setHeight(10); + root_child1.insertChild(root_child1_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child1_child1.getComputedLeft()).toBe(25); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(25); + expect(root_child1_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child2.getComputedLeft()).toBe(0); + expect(root_child1_child2.getComputedTop()).toBe(20); + expect(root_child1_child2.getComputedWidth()).toBe(25); + expect(root_child1_child2.getComputedHeight()).toBe(20); + + expect(root_child1_child3.getComputedLeft()).toBe(25); + expect(root_child1_child3.getComputedTop()).toBe(20); + expect(root_child1_child3.getComputedWidth()).toBe(25); + expect(root_child1_child3.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child1_child0.getComputedLeft()).toBe(25); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child1_child1.getComputedLeft()).toBe(0); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(25); + expect(root_child1_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child2.getComputedLeft()).toBe(25); + expect(root_child1_child2.getComputedTop()).toBe(20); + expect(root_child1_child2.getComputedWidth()).toBe(25); + expect(root_child1_child2.getComputedHeight()).toBe(20); + + expect(root_child1_child3.getComputedLeft()).toBe(0); + expect(root_child1_child3.getComputedTop()).toBe(20); + expect(root_child1_child3.getComputedWidth()).toBe(25); + expect(root_child1_child3.getComputedHeight()).toBe(10); }); test('align_baseline_child_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Baseline); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPosition(Edge.Top, 10); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setWidth(50); - root_child1_child0.setHeight(10); - root_child1.insertChild(root_child1_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPosition(Edge.Top, 10); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1.insertChild(root_child1_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); }); test('align_baseline_child_top2', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Baseline); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setPosition(Edge.Top, 5); - root_child1.setWidth(50); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setWidth(50); - root_child1_child0.setHeight(10); - root_child1.insertChild(root_child1_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(45); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(45); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPosition(Edge.Top, 5); + root_child1.setWidth(50); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1.insertChild(root_child1_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(45); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(45); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); }); test('align_baseline_double_nested_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Baseline); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setWidth(50); - root_child1_child0.setHeight(15); - root_child1.insertChild(root_child1_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(5); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(15); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(5); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(15); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(15); + root_child1.insertChild(root_child1_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(5); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(15); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(5); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(15); }); test('align_baseline_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Baseline); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); }); test('align_baseline_child_margin', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Baseline); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 5); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 5); - root_child0.setMargin(Edge.Bottom, 5); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setMargin(Edge.Left, 1); - root_child1_child0.setMargin(Edge.Top, 1); - root_child1_child0.setMargin(Edge.Right, 1); - root_child1_child0.setMargin(Edge.Bottom, 1); - root_child1_child0.setWidth(50); - root_child1_child0.setHeight(10); - root_child1.insertChild(root_child1_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(5); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(60); - expect(root_child1.getComputedTop()).toBe(44); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(1); - expect(root_child1_child0.getComputedTop()).toBe(1); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(45); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(-10); - expect(root_child1.getComputedTop()).toBe(44); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(-1); - expect(root_child1_child0.getComputedTop()).toBe(1); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 5); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 5); + root_child0.setMargin(Edge.Bottom, 5); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setMargin(Edge.Left, 1); + root_child1_child0.setMargin(Edge.Top, 1); + root_child1_child0.setMargin(Edge.Right, 1); + root_child1_child0.setMargin(Edge.Bottom, 1); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1.insertChild(root_child1_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(44); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(1); + expect(root_child1_child0.getComputedTop()).toBe(1); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(-10); + expect(root_child1.getComputedTop()).toBe(44); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(-1); + expect(root_child1_child0.getComputedTop()).toBe(1); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); }); test('align_baseline_child_padding', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Baseline); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 5); - root.setPadding(Edge.Top, 5); - root.setPadding(Edge.Right, 5); - root.setPadding(Edge.Bottom, 5); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setPadding(Edge.Left, 5); - root_child1.setPadding(Edge.Top, 5); - root_child1.setPadding(Edge.Right, 5); - root_child1.setPadding(Edge.Bottom, 5); - root_child1.setWidth(50); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setWidth(50); - root_child1_child0.setHeight(10); - root_child1.insertChild(root_child1_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(5); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(55); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(5); - expect(root_child1_child0.getComputedTop()).toBe(5); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(45); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(-5); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(-5); - expect(root_child1_child0.getComputedTop()).toBe(5); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 5); + root.setPadding(Edge.Top, 5); + root.setPadding(Edge.Right, 5); + root.setPadding(Edge.Bottom, 5); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPadding(Edge.Left, 5); + root_child1.setPadding(Edge.Top, 5); + root_child1.setPadding(Edge.Right, 5); + root_child1.setPadding(Edge.Bottom, 5); + root_child1.setWidth(50); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1.insertChild(root_child1_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(55); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(5); + expect(root_child1_child0.getComputedTop()).toBe(5); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(-5); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(-5); + expect(root_child1_child0.getComputedTop()).toBe(5); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); }); test('align_baseline_multiline', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Baseline); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setWidth(50); - root_child1_child0.setHeight(10); - root_child1.insertChild(root_child1_child0, 0); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(20); - root.insertChild(root_child2, 2); - - const root_child2_child0 = Yoga.Node.create(config); - root_child2_child0.setWidth(50); - root_child2_child0.setHeight(10); - root_child2.insertChild(root_child2_child0, 0); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root_child3.setHeight(50); - root.insertChild(root_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child2_child0.getComputedLeft()).toBe(0); - expect(root_child2_child0.getComputedTop()).toBe(0); - expect(root_child2_child0.getComputedWidth()).toBe(50); - expect(root_child2_child0.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(50); - expect(root_child3.getComputedTop()).toBe(60); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(50); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child2_child0.getComputedLeft()).toBe(0); - expect(root_child2_child0.getComputedTop()).toBe(0); - expect(root_child2_child0.getComputedWidth()).toBe(50); - expect(root_child2_child0.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(60); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + const root_child2_child0 = Yoga.Node.create(config); + root_child2_child0.setWidth(50); + root_child2_child0.setHeight(10); + root_child2.insertChild(root_child2_child0, 0); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(50); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child2_child0.getComputedLeft()).toBe(0); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(50); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(60); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child2_child0.getComputedLeft()).toBe(0); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(50); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(60); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); }); test.skip('align_baseline_multiline_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Baseline); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(30); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setWidth(20); - root_child1_child0.setHeight(20); - root_child1.insertChild(root_child1_child0, 0); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(40); - root_child2.setHeight(70); - root.insertChild(root_child2, 2); - - const root_child2_child0 = Yoga.Node.create(config); - root_child2_child0.setWidth(10); - root_child2_child0.setHeight(10); - root_child2.insertChild(root_child2_child0, 0); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root_child3.setHeight(20); - root.insertChild(root_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(20); - expect(root_child1_child0.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(50); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(70); - - expect(root_child2_child0.getComputedLeft()).toBe(0); - expect(root_child2_child0.getComputedTop()).toBe(0); - expect(root_child2_child0.getComputedWidth()).toBe(10); - expect(root_child2_child0.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(50); - expect(root_child3.getComputedTop()).toBe(70); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child1_child0.getComputedLeft()).toBe(10); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(20); - expect(root_child1_child0.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(70); - - expect(root_child2_child0.getComputedLeft()).toBe(30); - expect(root_child2_child0.getComputedTop()).toBe(0); - expect(root_child2_child0.getComputedWidth()).toBe(10); - expect(root_child2_child0.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(70); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(20); + root_child1_child0.setHeight(20); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(40); + root_child2.setHeight(70); + root.insertChild(root_child2, 2); + + const root_child2_child0 = Yoga.Node.create(config); + root_child2_child0.setWidth(10); + root_child2_child0.setHeight(10); + root_child2.insertChild(root_child2_child0, 0); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(20); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(20); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(70); + + expect(root_child2_child0.getComputedLeft()).toBe(0); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(10); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(70); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child1_child0.getComputedLeft()).toBe(10); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(20); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(70); + + expect(root_child2_child0.getComputedLeft()).toBe(30); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(10); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(70); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); }); test.skip('align_baseline_multiline_column2', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Baseline); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(30); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setWidth(20); - root_child1_child0.setHeight(20); - root_child1.insertChild(root_child1_child0, 0); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(40); - root_child2.setHeight(70); - root.insertChild(root_child2, 2); - - const root_child2_child0 = Yoga.Node.create(config); - root_child2_child0.setWidth(10); - root_child2_child0.setHeight(10); - root_child2.insertChild(root_child2_child0, 0); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root_child3.setHeight(20); - root.insertChild(root_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(20); - expect(root_child1_child0.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(50); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(70); - - expect(root_child2_child0.getComputedLeft()).toBe(0); - expect(root_child2_child0.getComputedTop()).toBe(0); - expect(root_child2_child0.getComputedWidth()).toBe(10); - expect(root_child2_child0.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(50); - expect(root_child3.getComputedTop()).toBe(70); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child1_child0.getComputedLeft()).toBe(10); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(20); - expect(root_child1_child0.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(70); - - expect(root_child2_child0.getComputedLeft()).toBe(30); - expect(root_child2_child0.getComputedTop()).toBe(0); - expect(root_child2_child0.getComputedWidth()).toBe(10); - expect(root_child2_child0.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(70); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(20); + root_child1_child0.setHeight(20); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(40); + root_child2.setHeight(70); + root.insertChild(root_child2, 2); + + const root_child2_child0 = Yoga.Node.create(config); + root_child2_child0.setWidth(10); + root_child2_child0.setHeight(10); + root_child2.insertChild(root_child2_child0, 0); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(20); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(20); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(70); + + expect(root_child2_child0.getComputedLeft()).toBe(0); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(10); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(70); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child1_child0.getComputedLeft()).toBe(10); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(20); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(70); + + expect(root_child2_child0.getComputedLeft()).toBe(30); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(10); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(70); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); }); test('align_baseline_multiline_row_and_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Baseline); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setWidth(50); - root_child1_child0.setHeight(10); - root_child1.insertChild(root_child1_child0, 0); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(20); - root.insertChild(root_child2, 2); - - const root_child2_child0 = Yoga.Node.create(config); - root_child2_child0.setWidth(50); - root_child2_child0.setHeight(10); - root_child2.insertChild(root_child2_child0, 0); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(50); - root_child3.setHeight(20); - root.insertChild(root_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child2_child0.getComputedLeft()).toBe(0); - expect(root_child2_child0.getComputedTop()).toBe(0); - expect(root_child2_child0.getComputedWidth()).toBe(50); - expect(root_child2_child0.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(50); - expect(root_child3.getComputedTop()).toBe(90); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(50); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child2_child0.getComputedLeft()).toBe(0); - expect(root_child2_child0.getComputedTop()).toBe(0); - expect(root_child2_child0.getComputedWidth()).toBe(50); - expect(root_child2_child0.getComputedHeight()).toBe(10); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(90); - expect(root_child3.getComputedWidth()).toBe(50); - expect(root_child3.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + const root_child2_child0 = Yoga.Node.create(config); + root_child2_child0.setWidth(50); + root_child2_child0.setHeight(10); + root_child2.insertChild(root_child2_child0, 0); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(20); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child2_child0.getComputedLeft()).toBe(0); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(50); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child2_child0.getComputedLeft()).toBe(0); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(50); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); }); test('align_items_center_child_with_margin_bigger_than_parent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(52); - root.setHeight(52); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignItems(Align.Center); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setMargin(Edge.Left, 10); - root_child0_child0.setMargin(Edge.Right, 10); - root_child0_child0.setWidth(52); - root_child0_child0.setHeight(52); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(-10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(52); - - expect(root_child0_child0.getComputedLeft()).toBe(10); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(52); - expect(root_child0_child0.getComputedHeight()).toBe(52); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(-10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(52); - - expect(root_child0_child0.getComputedLeft()).toBe(10); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(52); - expect(root_child0_child0.getComputedHeight()).toBe(52); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignItems(Align.Center); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setMargin(Edge.Left, 10); + root_child0_child0.setMargin(Edge.Right, 10); + root_child0_child0.setWidth(52); + root_child0_child0.setHeight(52); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(52); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(52); + expect(root_child0_child0.getComputedHeight()).toBe(52); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(52); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(52); + expect(root_child0_child0.getComputedHeight()).toBe(52); }); test('align_items_flex_end_child_with_margin_bigger_than_parent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(52); - root.setHeight(52); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignItems(Align.FlexEnd); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setMargin(Edge.Left, 10); - root_child0_child0.setMargin(Edge.Right, 10); - root_child0_child0.setWidth(52); - root_child0_child0.setHeight(52); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(-10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(52); - - expect(root_child0_child0.getComputedLeft()).toBe(10); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(52); - expect(root_child0_child0.getComputedHeight()).toBe(52); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(-10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(52); - - expect(root_child0_child0.getComputedLeft()).toBe(10); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(52); - expect(root_child0_child0.getComputedHeight()).toBe(52); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignItems(Align.FlexEnd); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setMargin(Edge.Left, 10); + root_child0_child0.setMargin(Edge.Right, 10); + root_child0_child0.setWidth(52); + root_child0_child0.setHeight(52); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(52); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(52); + expect(root_child0_child0.getComputedHeight()).toBe(52); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(52); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(52); + expect(root_child0_child0.getComputedHeight()).toBe(52); }); test('align_items_center_child_without_margin_bigger_than_parent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(52); - root.setHeight(52); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignItems(Align.Center); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(72); - root_child0_child0.setHeight(72); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(-10); - expect(root_child0.getComputedTop()).toBe(-10); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(72); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(72); - expect(root_child0_child0.getComputedHeight()).toBe(72); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(-10); - expect(root_child0.getComputedTop()).toBe(-10); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(72); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(72); - expect(root_child0_child0.getComputedHeight()).toBe(72); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignItems(Align.Center); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(72); + root_child0_child0.setHeight(72); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0.getComputedHeight()).toBe(72); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0.getComputedHeight()).toBe(72); }); test('align_items_flex_end_child_without_margin_bigger_than_parent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(52); - root.setHeight(52); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignItems(Align.FlexEnd); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(72); - root_child0_child0.setHeight(72); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(-10); - expect(root_child0.getComputedTop()).toBe(-10); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(72); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(72); - expect(root_child0_child0.getComputedHeight()).toBe(72); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(-10); - expect(root_child0.getComputedTop()).toBe(-10); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(72); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(72); - expect(root_child0_child0.getComputedHeight()).toBe(72); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignItems(Align.FlexEnd); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(72); + root_child0_child0.setHeight(72); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0.getComputedHeight()).toBe(72); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0.getComputedHeight()).toBe(72); }); test('align_center_should_size_based_on_content', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setMargin(Edge.Top, 20); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setJustifyContent(Justify.Center); - root_child0.setFlexShrink(1); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setWidth(20); - root_child0_child0_child0.setHeight(20); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(20); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(40); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(20); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(40); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Top, 20); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.Center); + root_child0.setFlexShrink(1); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(20); + root_child0_child0_child0.setHeight(20); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(20); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(20); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(20); }); test('align_stretch_should_size_based_on_parent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setMargin(Edge.Top, 20); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setJustifyContent(Justify.Center); - root_child0.setFlexShrink(1); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setWidth(20); - root_child0_child0_child0.setHeight(20); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(20); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(20); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(80); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Top, 20); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.Center); + root_child0.setFlexShrink(1); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(20); + root_child0_child0_child0.setHeight(20); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(20); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(20); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(20); }); test('align_flex_start_with_shrinking_children', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(500); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignItems(Align.FlexStart); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setFlexGrow(1); - root_child0_child0_child0.setFlexShrink(1); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0_child0.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(500); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0_child0.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignItems(Align.FlexStart); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setFlexGrow(1); + root_child0_child0_child0.setFlexShrink(1); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(500); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0.getComputedHeight()).toBe(0); }); test('align_flex_start_with_stretching_children', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(500); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setFlexGrow(1); - root_child0_child0_child0.setFlexShrink(1); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(500); - expect(root_child0_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(500); - expect(root_child0_child0_child0.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(500); - expect(root_child0_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(500); - expect(root_child0_child0_child0.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setFlexGrow(1); + root_child0_child0_child0.setFlexShrink(1); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(500); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(500); + expect(root_child0_child0_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(500); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(500); + expect(root_child0_child0_child0.getComputedHeight()).toBe(0); }); test('align_flex_start_with_shrinking_children_with_stretch', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(500); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignItems(Align.FlexStart); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setFlexGrow(1); - root_child0_child0_child0.setFlexShrink(1); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0_child0.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(500); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0_child0.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignItems(Align.FlexStart); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setFlexGrow(1); + root_child0_child0_child0.setFlexShrink(1); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(500); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0.getComputedHeight()).toBe(0); }); test('align_flex_end_with_row_reverse', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(75); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 3); - root_child0.setMargin(Edge.Right, 5); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(75); - - expect(root_child0.getComputedLeft()).toBe(3); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(58); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(75); - - expect(root_child0.getComputedLeft()).toBe(45); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(-8); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(75); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 3); + root_child0.setMargin(Edge.Right, 5); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(75); + + expect(root_child0.getComputedLeft()).toBe(3); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(58); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(75); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(-8); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('align_stretch_with_row_reverse', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(75); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 3); - root_child0.setMargin(Edge.Right, 5); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(75); - - expect(root_child0.getComputedLeft()).toBe(3); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(58); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(75); - - expect(root_child0.getComputedLeft()).toBe(45); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(-8); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(75); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 3); + root_child0.setMargin(Edge.Right, 5); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(75); + + expect(root_child0.getComputedLeft()).toBe(3); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(58); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(75); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(-8); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('align_items_non_stretch_s526008', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(400); - root.setHeight(400); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setAlignItems(Align.FlexStart); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0.setHeight(10); - root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(400); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setAlignItems(Align.FlexStart); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setHeight(10); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(400); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(10); }); diff --git a/javascript/tests/generated/YGAlignSelfTest.test.ts b/javascript/tests/generated/YGAlignSelfTest.test.ts index 5d2e49ecc9..b13ba7ea69 100644 --- a/javascript/tests/generated/YGAlignSelfTest.test.ts +++ b/javascript/tests/generated/YGAlignSelfTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<1badc9ed5a0cb8d9a4a1b23653cfbe58>> + * @generated SignedSource<<9d71a3beb2b1041ea5523d2aedf5ed39>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignSelfTest.html */ @@ -30,264 +30,219 @@ import { test('align_self_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignSelf(Align.Center); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(45); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(45); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.Center); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('align_self_flex_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignSelf(Align.FlexEnd); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexEnd); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('align_self_flex_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignSelf(Align.FlexStart); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexStart); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('align_self_flex_end_override_flex_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignSelf(Align.FlexEnd); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexEnd); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('align_self_baseline', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setAlignSelf(Align.Baseline); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setAlignSelf(Align.Baseline); - root_child1.setWidth(50); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setWidth(50); - root_child1_child0.setHeight(10); - root_child1.insertChild(root_child1_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(50); - expect(root_child1_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.Baseline); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setAlignSelf(Align.Baseline); + root_child1.setWidth(50); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1.insertChild(root_child1_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); }); diff --git a/javascript/tests/generated/YGAndroidNewsFeed.test.ts b/javascript/tests/generated/YGAndroidNewsFeed.test.ts index 488ed8d531..ba74393891 100644 --- a/javascript/tests/generated/YGAndroidNewsFeed.test.ts +++ b/javascript/tests/generated/YGAndroidNewsFeed.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAndroidNewsFeed.html */ @@ -30,286 +30,277 @@ import { test('android_news_feed', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setWidth(1080); - - const root_child0 = Yoga.Node.create(config); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setAlignContent(Align.Stretch); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setAlignContent(Align.Stretch); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0_child0_child0_child0.setAlignContent(Align.Stretch); - root_child0_child0_child0_child0.setAlignItems(Align.FlexStart); - root_child0_child0_child0_child0.setMargin(Edge.Start, 36); - root_child0_child0_child0_child0.setMargin(Edge.Top, 24); - root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); - - const root_child0_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0_child0_child0_child0_child0.setAlignContent(Align.Stretch); - root_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0, 0); - - const root_child0_child0_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0_child0_child0.setAlignContent(Align.Stretch); - root_child0_child0_child0_child0_child0_child0.setWidth(120); - root_child0_child0_child0_child0_child0_child0.setHeight(120); - root_child0_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0_child0, 0); - - const root_child0_child0_child0_child0_child1 = Yoga.Node.create(config); - root_child0_child0_child0_child0_child1.setAlignContent(Align.Stretch); - root_child0_child0_child0_child0_child1.setFlexShrink(1); - root_child0_child0_child0_child0_child1.setMargin(Edge.Right, 36); - root_child0_child0_child0_child0_child1.setPadding(Edge.Left, 36); - root_child0_child0_child0_child0_child1.setPadding(Edge.Top, 21); - root_child0_child0_child0_child0_child1.setPadding(Edge.Right, 36); - root_child0_child0_child0_child0_child1.setPadding(Edge.Bottom, 18); - root_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child1, 1); - - const root_child0_child0_child0_child0_child1_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0_child1_child0.setFlexDirection(FlexDirection.Row); - root_child0_child0_child0_child0_child1_child0.setAlignContent(Align.Stretch); - root_child0_child0_child0_child0_child1_child0.setFlexShrink(1); - root_child0_child0_child0_child0_child1.insertChild(root_child0_child0_child0_child0_child1_child0, 0); - - const root_child0_child0_child0_child0_child1_child1 = Yoga.Node.create(config); - root_child0_child0_child0_child0_child1_child1.setAlignContent(Align.Stretch); - root_child0_child0_child0_child0_child1_child1.setFlexShrink(1); - root_child0_child0_child0_child0_child1.insertChild(root_child0_child0_child0_child0_child1_child1, 1); - - const root_child0_child0_child1 = Yoga.Node.create(config); - root_child0_child0_child1.setAlignContent(Align.Stretch); - root_child0_child0.insertChild(root_child0_child0_child1, 1); - - const root_child0_child0_child1_child0 = Yoga.Node.create(config); - root_child0_child0_child1_child0.setFlexDirection(FlexDirection.Row); - root_child0_child0_child1_child0.setAlignContent(Align.Stretch); - root_child0_child0_child1_child0.setAlignItems(Align.FlexStart); - root_child0_child0_child1_child0.setMargin(Edge.Start, 174); - root_child0_child0_child1_child0.setMargin(Edge.Top, 24); - root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); - - const root_child0_child0_child1_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child1_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0_child0_child1_child0_child0.setAlignContent(Align.Stretch); - root_child0_child0_child1_child0.insertChild(root_child0_child0_child1_child0_child0, 0); - - const root_child0_child0_child1_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child1_child0_child0_child0.setAlignContent(Align.Stretch); - root_child0_child0_child1_child0_child0_child0.setWidth(72); - root_child0_child0_child1_child0_child0_child0.setHeight(72); - root_child0_child0_child1_child0_child0.insertChild(root_child0_child0_child1_child0_child0_child0, 0); - - const root_child0_child0_child1_child0_child1 = Yoga.Node.create(config); - root_child0_child0_child1_child0_child1.setAlignContent(Align.Stretch); - root_child0_child0_child1_child0_child1.setFlexShrink(1); - root_child0_child0_child1_child0_child1.setMargin(Edge.Right, 36); - root_child0_child0_child1_child0_child1.setPadding(Edge.Left, 36); - root_child0_child0_child1_child0_child1.setPadding(Edge.Top, 21); - root_child0_child0_child1_child0_child1.setPadding(Edge.Right, 36); - root_child0_child0_child1_child0_child1.setPadding(Edge.Bottom, 18); - root_child0_child0_child1_child0.insertChild(root_child0_child0_child1_child0_child1, 1); - - const root_child0_child0_child1_child0_child1_child0 = Yoga.Node.create(config); - root_child0_child0_child1_child0_child1_child0.setFlexDirection(FlexDirection.Row); - root_child0_child0_child1_child0_child1_child0.setAlignContent(Align.Stretch); - root_child0_child0_child1_child0_child1_child0.setFlexShrink(1); - root_child0_child0_child1_child0_child1.insertChild(root_child0_child0_child1_child0_child1_child0, 0); - - const root_child0_child0_child1_child0_child1_child1 = Yoga.Node.create(config); - root_child0_child0_child1_child0_child1_child1.setAlignContent(Align.Stretch); - root_child0_child0_child1_child0_child1_child1.setFlexShrink(1); - root_child0_child0_child1_child0_child1.insertChild(root_child0_child0_child1_child0_child1_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(1080); - expect(root.getComputedHeight()).toBe(240); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(1080); - expect(root_child0.getComputedHeight()).toBe(240); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(1080); - expect(root_child0_child0.getComputedHeight()).toBe(240); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(1080); - expect(root_child0_child0_child0.getComputedHeight()).toBe(144); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(36); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(24); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(1044); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(120); - - expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120); - expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120); - - expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120); - expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120); - - expect(root_child0_child0_child0_child0_child1.getComputedLeft()).toBe(120); - expect(root_child0_child0_child0_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child0_child0_child0_child1.getComputedWidth()).toBe(72); - expect(root_child0_child0_child0_child0_child1.getComputedHeight()).toBe(39); - - expect(root_child0_child0_child0_child0_child1_child0.getComputedLeft()).toBe(36); - expect(root_child0_child0_child0_child0_child1_child0.getComputedTop()).toBe(21); - expect(root_child0_child0_child0_child0_child1_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0_child0_child0_child1_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child0_child0_child1_child1.getComputedLeft()).toBe(36); - expect(root_child0_child0_child0_child0_child1_child1.getComputedTop()).toBe(21); - expect(root_child0_child0_child0_child0_child1_child1.getComputedWidth()).toBe(0); - expect(root_child0_child0_child0_child0_child1_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child0_child1.getComputedTop()).toBe(144); - expect(root_child0_child0_child1.getComputedWidth()).toBe(1080); - expect(root_child0_child0_child1.getComputedHeight()).toBe(96); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(174); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(24); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(906); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(72); - - expect(root_child0_child0_child1_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child1_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child1_child0_child0.getComputedWidth()).toBe(72); - expect(root_child0_child0_child1_child0_child0.getComputedHeight()).toBe(72); - - expect(root_child0_child0_child1_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child1_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child1_child0_child0_child0.getComputedWidth()).toBe(72); - expect(root_child0_child0_child1_child0_child0_child0.getComputedHeight()).toBe(72); - - expect(root_child0_child0_child1_child0_child1.getComputedLeft()).toBe(72); - expect(root_child0_child0_child1_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child0_child1_child0_child1.getComputedWidth()).toBe(72); - expect(root_child0_child0_child1_child0_child1.getComputedHeight()).toBe(39); - - expect(root_child0_child0_child1_child0_child1_child0.getComputedLeft()).toBe(36); - expect(root_child0_child0_child1_child0_child1_child0.getComputedTop()).toBe(21); - expect(root_child0_child0_child1_child0_child1_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0_child1_child0_child1_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child1_child0_child1_child1.getComputedLeft()).toBe(36); - expect(root_child0_child0_child1_child0_child1_child1.getComputedTop()).toBe(21); - expect(root_child0_child0_child1_child0_child1_child1.getComputedWidth()).toBe(0); - expect(root_child0_child0_child1_child0_child1_child1.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(1080); - expect(root.getComputedHeight()).toBe(240); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(1080); - expect(root_child0.getComputedHeight()).toBe(240); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(1080); - expect(root_child0_child0.getComputedHeight()).toBe(240); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(1080); - expect(root_child0_child0_child0.getComputedHeight()).toBe(144); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(24); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(1044); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(120); - - expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(924); - expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120); - expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120); - - expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120); - expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120); - - expect(root_child0_child0_child0_child0_child1.getComputedLeft()).toBe(816); - expect(root_child0_child0_child0_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child0_child0_child0_child1.getComputedWidth()).toBe(72); - expect(root_child0_child0_child0_child0_child1.getComputedHeight()).toBe(39); - - expect(root_child0_child0_child0_child0_child1_child0.getComputedLeft()).toBe(36); - expect(root_child0_child0_child0_child0_child1_child0.getComputedTop()).toBe(21); - expect(root_child0_child0_child0_child0_child1_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0_child0_child0_child1_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child0_child0_child1_child1.getComputedLeft()).toBe(36); - expect(root_child0_child0_child0_child0_child1_child1.getComputedTop()).toBe(21); - expect(root_child0_child0_child0_child0_child1_child1.getComputedWidth()).toBe(0); - expect(root_child0_child0_child0_child0_child1_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child0_child1.getComputedTop()).toBe(144); - expect(root_child0_child0_child1.getComputedWidth()).toBe(1080); - expect(root_child0_child0_child1.getComputedHeight()).toBe(96); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(24); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(906); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(72); - - expect(root_child0_child0_child1_child0_child0.getComputedLeft()).toBe(834); - expect(root_child0_child0_child1_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child1_child0_child0.getComputedWidth()).toBe(72); - expect(root_child0_child0_child1_child0_child0.getComputedHeight()).toBe(72); - - expect(root_child0_child0_child1_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child1_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child1_child0_child0_child0.getComputedWidth()).toBe(72); - expect(root_child0_child0_child1_child0_child0_child0.getComputedHeight()).toBe(72); - - expect(root_child0_child0_child1_child0_child1.getComputedLeft()).toBe(726); - expect(root_child0_child0_child1_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child0_child1_child0_child1.getComputedWidth()).toBe(72); - expect(root_child0_child0_child1_child0_child1.getComputedHeight()).toBe(39); - - expect(root_child0_child0_child1_child0_child1_child0.getComputedLeft()).toBe(36); - expect(root_child0_child0_child1_child0_child1_child0.getComputedTop()).toBe(21); - expect(root_child0_child0_child1_child0_child1_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0_child1_child0_child1_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child1_child0_child1_child1.getComputedLeft()).toBe(36); - expect(root_child0_child0_child1_child0_child1_child1.getComputedTop()).toBe(21); - expect(root_child0_child0_child1_child0_child1_child1.getComputedWidth()).toBe(0); - expect(root_child0_child0_child1_child0_child1_child1.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setWidth(1080); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setAlignContent(Align.Stretch); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0_child0_child0.setAlignItems(Align.FlexStart); + root_child0_child0_child0_child0.setMargin(Edge.Start, 36); + root_child0_child0_child0_child0.setMargin(Edge.Top, 24); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child0_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0, 0); + + const root_child0_child0_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0_child0_child0_child0_child0.setWidth(120); + root_child0_child0_child0_child0_child0_child0.setHeight(120); + root_child0_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0_child0, 0); + + const root_child0_child0_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child0_child0_child1.setAlignContent(Align.Stretch); + root_child0_child0_child0_child0_child1.setFlexShrink(1); + root_child0_child0_child0_child0_child1.setMargin(Edge.Right, 36); + root_child0_child0_child0_child0_child1.setPadding(Edge.Left, 36); + root_child0_child0_child0_child0_child1.setPadding(Edge.Top, 21); + root_child0_child0_child0_child0_child1.setPadding(Edge.Right, 36); + root_child0_child0_child0_child0_child1.setPadding(Edge.Bottom, 18); + root_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child1, 1); + + const root_child0_child0_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0_child1_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child0_child0_child1_child0.setAlignContent(Align.Stretch); + root_child0_child0_child0_child0_child1_child0.setFlexShrink(1); + root_child0_child0_child0_child0_child1.insertChild(root_child0_child0_child0_child0_child1_child0, 0); + + const root_child0_child0_child0_child0_child1_child1 = Yoga.Node.create(config); + root_child0_child0_child0_child0_child1_child1.setAlignContent(Align.Stretch); + root_child0_child0_child0_child0_child1_child1.setFlexShrink(1); + root_child0_child0_child0_child0_child1.insertChild(root_child0_child0_child0_child0_child1_child1, 1); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setAlignContent(Align.Stretch); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child1_child0.setAlignContent(Align.Stretch); + root_child0_child0_child1_child0.setAlignItems(Align.FlexStart); + root_child0_child0_child1_child0.setMargin(Edge.Start, 174); + root_child0_child0_child1_child0.setMargin(Edge.Top, 24); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child1_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child1_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0_child1_child0.insertChild(root_child0_child0_child1_child0_child0, 0); + + const root_child0_child0_child1_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0_child1_child0_child0_child0.setWidth(72); + root_child0_child0_child1_child0_child0_child0.setHeight(72); + root_child0_child0_child1_child0_child0.insertChild(root_child0_child0_child1_child0_child0_child0, 0); + + const root_child0_child0_child1_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1_child0_child1.setAlignContent(Align.Stretch); + root_child0_child0_child1_child0_child1.setFlexShrink(1); + root_child0_child0_child1_child0_child1.setMargin(Edge.Right, 36); + root_child0_child0_child1_child0_child1.setPadding(Edge.Left, 36); + root_child0_child0_child1_child0_child1.setPadding(Edge.Top, 21); + root_child0_child0_child1_child0_child1.setPadding(Edge.Right, 36); + root_child0_child0_child1_child0_child1.setPadding(Edge.Bottom, 18); + root_child0_child0_child1_child0.insertChild(root_child0_child0_child1_child0_child1, 1); + + const root_child0_child0_child1_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0_child1_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child1_child0_child1_child0.setAlignContent(Align.Stretch); + root_child0_child0_child1_child0_child1_child0.setFlexShrink(1); + root_child0_child0_child1_child0_child1.insertChild(root_child0_child0_child1_child0_child1_child0, 0); + + const root_child0_child0_child1_child0_child1_child1 = Yoga.Node.create(config); + root_child0_child0_child1_child0_child1_child1.setAlignContent(Align.Stretch); + root_child0_child0_child1_child0_child1_child1.setFlexShrink(1); + root_child0_child0_child1_child0_child1.insertChild(root_child0_child0_child1_child0_child1_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(1080); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1080); + expect(root_child0.getComputedHeight()).toBe(240); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(1080); + expect(root_child0_child0.getComputedHeight()).toBe(240); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(1080); + expect(root_child0_child0_child0.getComputedHeight()).toBe(144); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(36); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(24); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(1044); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120); + expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120); + expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0_child0_child0_child1.getComputedLeft()).toBe(120); + expect(root_child0_child0_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child1.getComputedWidth()).toBe(72); + expect(root_child0_child0_child0_child0_child1.getComputedHeight()).toBe(39); + + expect(root_child0_child0_child0_child0_child1_child0.getComputedLeft()).toBe(36); + expect(root_child0_child0_child0_child0_child1_child0.getComputedTop()).toBe(21); + expect(root_child0_child0_child0_child0_child1_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0_child0_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child0_child0_child1_child1.getComputedLeft()).toBe(36); + expect(root_child0_child0_child0_child0_child1_child1.getComputedTop()).toBe(21); + expect(root_child0_child0_child0_child0_child1_child1.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0_child0_child1_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1.getComputedTop()).toBe(144); + expect(root_child0_child0_child1.getComputedWidth()).toBe(1080); + expect(root_child0_child0_child1.getComputedHeight()).toBe(96); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(174); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(24); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(906); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0_child1_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child1_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0_child1_child0_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0_child1_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child1_child0_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0_child1_child0_child0_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0_child1_child0_child1.getComputedLeft()).toBe(72); + expect(root_child0_child0_child1_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1_child0_child1.getComputedWidth()).toBe(72); + expect(root_child0_child0_child1_child0_child1.getComputedHeight()).toBe(39); + + expect(root_child0_child0_child1_child0_child1_child0.getComputedLeft()).toBe(36); + expect(root_child0_child0_child1_child0_child1_child0.getComputedTop()).toBe(21); + expect(root_child0_child0_child1_child0_child1_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child1_child0_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child1_child0_child1_child1.getComputedLeft()).toBe(36); + expect(root_child0_child0_child1_child0_child1_child1.getComputedTop()).toBe(21); + expect(root_child0_child0_child1_child0_child1_child1.getComputedWidth()).toBe(0); + expect(root_child0_child0_child1_child0_child1_child1.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(1080); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1080); + expect(root_child0.getComputedHeight()).toBe(240); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(1080); + expect(root_child0_child0.getComputedHeight()).toBe(240); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(1080); + expect(root_child0_child0_child0.getComputedHeight()).toBe(144); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(24); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(1044); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(924); + expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120); + expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120); + expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0_child0_child0_child1.getComputedLeft()).toBe(816); + expect(root_child0_child0_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child1.getComputedWidth()).toBe(72); + expect(root_child0_child0_child0_child0_child1.getComputedHeight()).toBe(39); + + expect(root_child0_child0_child0_child0_child1_child0.getComputedLeft()).toBe(36); + expect(root_child0_child0_child0_child0_child1_child0.getComputedTop()).toBe(21); + expect(root_child0_child0_child0_child0_child1_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0_child0_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child0_child0_child1_child1.getComputedLeft()).toBe(36); + expect(root_child0_child0_child0_child0_child1_child1.getComputedTop()).toBe(21); + expect(root_child0_child0_child0_child0_child1_child1.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0_child0_child1_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1.getComputedTop()).toBe(144); + expect(root_child0_child0_child1.getComputedWidth()).toBe(1080); + expect(root_child0_child0_child1.getComputedHeight()).toBe(96); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(24); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(906); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0_child1_child0_child0.getComputedLeft()).toBe(834); + expect(root_child0_child0_child1_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child1_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0_child1_child0_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0_child1_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child1_child0_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0_child1_child0_child0_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0_child1_child0_child1.getComputedLeft()).toBe(726); + expect(root_child0_child0_child1_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1_child0_child1.getComputedWidth()).toBe(72); + expect(root_child0_child0_child1_child0_child1.getComputedHeight()).toBe(39); + + expect(root_child0_child0_child1_child0_child1_child0.getComputedLeft()).toBe(36); + expect(root_child0_child0_child1_child0_child1_child0.getComputedTop()).toBe(21); + expect(root_child0_child0_child1_child0_child1_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child1_child0_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child1_child0_child1_child1.getComputedLeft()).toBe(36); + expect(root_child0_child0_child1_child0_child1_child1.getComputedTop()).toBe(21); + expect(root_child0_child0_child1_child0_child1_child1.getComputedWidth()).toBe(0); + expect(root_child0_child0_child1_child0_child1_child1.getComputedHeight()).toBe(0); }); diff --git a/javascript/tests/generated/YGAspectRatioTest.test.ts b/javascript/tests/generated/YGAspectRatioTest.test.ts index 69a7427809..ab635a5f85 100644 --- a/javascript/tests/generated/YGAspectRatioTest.test.ts +++ b/javascript/tests/generated/YGAspectRatioTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<57064c3213fc22e0637ae5768ce6fea5>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAspectRatioTest.html */ @@ -30,202 +30,184 @@ import { test.skip('aspect_ratio_does_not_stretch_cross_axis_dim', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(300); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setOverflow(Overflow.Scroll); - root_child0.setFlexGrow(1); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis("0%"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setFlexGrow(2); - root_child0_child0_child0.setFlexShrink(1); - root_child0_child0_child0.setFlexBasis("0%"); - root_child0_child0_child0.setAspectRatio(1 / 1); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child1 = Yoga.Node.create(config); - root_child0_child0_child1.setWidth(5); - root_child0_child0.insertChild(root_child0_child0_child1, 1); - - const root_child0_child0_child2 = Yoga.Node.create(config); - root_child0_child0_child2.setFlexGrow(1); - root_child0_child0_child2.setFlexShrink(1); - root_child0_child0_child2.setFlexBasis("0%"); - root_child0_child0.insertChild(root_child0_child0_child2, 2); - - const root_child0_child0_child2_child0 = Yoga.Node.create(config); - root_child0_child0_child2_child0.setFlexGrow(1); - root_child0_child0_child2_child0.setFlexShrink(1); - root_child0_child0_child2_child0.setFlexBasis("0%"); - root_child0_child0_child2_child0.setAspectRatio(1 / 1); - root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); - - const root_child0_child0_child2_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child2_child0_child0.setWidth(5); - root_child0_child0_child2_child0.insertChild(root_child0_child0_child2_child0_child0, 0); - - const root_child0_child0_child2_child0_child1 = Yoga.Node.create(config); - root_child0_child0_child2_child0_child1.setFlexGrow(1); - root_child0_child0_child2_child0_child1.setFlexShrink(1); - root_child0_child0_child2_child0_child1.setFlexBasis("0%"); - root_child0_child0_child2_child0_child1.setAspectRatio(1 / 1); - root_child0_child0_child2_child0.insertChild(root_child0_child0_child2_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(300); - expect(root_child0.getComputedHeight()).toBe(300); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(300); - expect(root_child0_child0.getComputedHeight()).toBe(197); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(197); - expect(root_child0_child0_child0.getComputedHeight()).toBe(197); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(197); - expect(root_child0_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child0_child1.getComputedWidth()).toBe(5); - expect(root_child0_child0_child1.getComputedHeight()).toBe(197); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(202); - expect(root_child0_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child0_child2.getComputedWidth()).toBe(98); - expect(root_child0_child0_child2.getComputedHeight()).toBe(197); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(98); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(197); - - expect(root_child0_child0_child2_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child2_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child2_child0_child0.getComputedWidth()).toBe(5); - expect(root_child0_child0_child2_child0_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child2_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child0_child2_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child0_child2_child0_child1.getComputedWidth()).toBe(98); - expect(root_child0_child0_child2_child0_child1.getComputedHeight()).toBe(197); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(300); - expect(root_child0.getComputedHeight()).toBe(300); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(300); - expect(root_child0_child0.getComputedHeight()).toBe(197); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(103); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(197); - expect(root_child0_child0_child0.getComputedHeight()).toBe(197); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(98); - expect(root_child0_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child0_child1.getComputedWidth()).toBe(5); - expect(root_child0_child0_child1.getComputedHeight()).toBe(197); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child0_child2.getComputedWidth()).toBe(98); - expect(root_child0_child0_child2.getComputedHeight()).toBe(197); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(98); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(197); - - expect(root_child0_child0_child2_child0_child0.getComputedLeft()).toBe(93); - expect(root_child0_child0_child2_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child2_child0_child0.getComputedWidth()).toBe(5); - expect(root_child0_child0_child2_child0_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child2_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child0_child2_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child0_child2_child0_child1.getComputedWidth()).toBe(98); - expect(root_child0_child0_child2_child0_child1.getComputedHeight()).toBe(197); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setOverflow(Overflow.Scroll); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setFlexGrow(2); + root_child0_child0_child0.setFlexShrink(1); + root_child0_child0_child0.setFlexBasis("0%"); + root_child0_child0_child0.setAspectRatio(1 / 1); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setWidth(5); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setFlexGrow(1); + root_child0_child0_child2.setFlexShrink(1); + root_child0_child0_child2.setFlexBasis("0%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setFlexGrow(1); + root_child0_child0_child2_child0.setFlexShrink(1); + root_child0_child0_child2_child0.setFlexBasis("0%"); + root_child0_child0_child2_child0.setAspectRatio(1 / 1); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + + const root_child0_child0_child2_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0_child0.setWidth(5); + root_child0_child0_child2_child0.insertChild(root_child0_child0_child2_child0_child0, 0); + + const root_child0_child0_child2_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child2_child0_child1.setFlexGrow(1); + root_child0_child0_child2_child0_child1.setFlexShrink(1); + root_child0_child0_child2_child0_child1.setFlexBasis("0%"); + root_child0_child0_child2_child0_child1.setAspectRatio(1 / 1); + root_child0_child0_child2_child0.insertChild(root_child0_child0_child2_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(300); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(300); + expect(root_child0_child0.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(197); + expect(root_child0_child0_child0.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(197); + expect(root_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1.getComputedWidth()).toBe(5); + expect(root_child0_child0_child1.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(202); + expect(root_child0_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child0_child2.getComputedWidth()).toBe(98); + expect(root_child0_child0_child2.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(98); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child2_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child2_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child2_child0_child0.getComputedWidth()).toBe(5); + expect(root_child0_child0_child2_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child2_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child0_child2_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child2_child0_child1.getComputedWidth()).toBe(98); + expect(root_child0_child0_child2_child0_child1.getComputedHeight()).toBe(197); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(300); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(300); + expect(root_child0_child0.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(103); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(197); + expect(root_child0_child0_child0.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(98); + expect(root_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1.getComputedWidth()).toBe(5); + expect(root_child0_child0_child1.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child0_child2.getComputedWidth()).toBe(98); + expect(root_child0_child0_child2.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(98); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child2_child0_child0.getComputedLeft()).toBe(93); + expect(root_child0_child0_child2_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child2_child0_child0.getComputedWidth()).toBe(5); + expect(root_child0_child0_child2_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child2_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child0_child2_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child2_child0_child1.getComputedWidth()).toBe(98); + expect(root_child0_child0_child2_child0_child1.getComputedHeight()).toBe(197); }); test('zero_aspect_ratio_behaves_like_auto', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(300); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setAspectRatio(0 / 1); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(250); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setAspectRatio(0 / 1); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(250); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); }); diff --git a/javascript/tests/generated/YGAutoTest.test.ts b/javascript/tests/generated/YGAutoTest.test.ts index 5e9557dc0f..1165722249 100644 --- a/javascript/tests/generated/YGAutoTest.test.ts +++ b/javascript/tests/generated/YGAutoTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<234cdb7f76ac586e034a5b6ca2033fa4>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAutoTest.html */ @@ -30,318 +30,273 @@ import { test('auto_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth('auto'); - root.setHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(100); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth('auto'); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); }); test('auto_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(50); - root.setHeight('auto'); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(50); + root.setHeight('auto'); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); }); test('auto_flex_basis', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); }); test('auto_position', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(50); - root.setHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionAuto(Edge.Right); - root_child0.setWidth(25); - root_child0.setHeight(25); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(25); - expect(root_child0.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(25); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(25); - expect(root_child0.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(50); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionAuto(Edge.Right); + root_child0.setWidth(25); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); }); test('auto_margin', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(50); - root.setHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 'auto'); - root_child0.setWidth(25); - root_child0.setHeight(25); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(25); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(25); - expect(root_child0.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(25); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(25); - expect(root_child0.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(50); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setWidth(25); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); }); diff --git a/javascript/tests/generated/YGBorderTest.test.ts b/javascript/tests/generated/YGBorderTest.test.ts index ddbdd2aad1..25b4f7bb19 100644 --- a/javascript/tests/generated/YGBorderTest.test.ts +++ b/javascript/tests/generated/YGBorderTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<3dba13091d34f5dbd73ce4a89a3b4d7e>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBorderTest.html */ @@ -30,227 +30,182 @@ import { test('border_no_size', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 10); - root.setBorder(Edge.Top, 10); - root.setBorder(Edge.Right, 10); - root.setBorder(Edge.Bottom, 10); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(20); - expect(root.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(20); - expect(root.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(20); }); test('border_container_match_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 10); - root.setBorder(Edge.Top, 10); - root.setBorder(Edge.Right, 10); - root.setBorder(Edge.Bottom, 10); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(30); - expect(root.getComputedHeight()).toBe(30); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(30); - expect(root.getComputedHeight()).toBe(30); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(30); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(30); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('border_flex_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 10); - root.setBorder(Edge.Top, 10); - root.setBorder(Edge.Right, 10); - root.setBorder(Edge.Bottom, 10); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(80); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(80); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(80); }); test('border_stretch_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 10); - root.setBorder(Edge.Top, 10); - root.setBorder(Edge.Right, 10); - root.setBorder(Edge.Bottom, 10); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(80); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(80); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(10); }); test('border_center_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Start, 10); - root.setBorder(Edge.End, 20); - root.setBorder(Edge.Bottom, 20); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(40); - expect(root_child0.getComputedTop()).toBe(35); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(35); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Start, 10); + root.setBorder(Edge.End, 20); + root.setBorder(Edge.Bottom, 20); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(35); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(35); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); diff --git a/javascript/tests/generated/YGBoxSizingTest.test.ts b/javascript/tests/generated/YGBoxSizingTest.test.ts index d967870518..da3478cbb0 100644 --- a/javascript/tests/generated/YGBoxSizingTest.test.ts +++ b/javascript/tests/generated/YGBoxSizingTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBoxSizingTest.html */ @@ -30,2718 +30,2286 @@ import { test('box_sizing_content_box_simple', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 5); - root.setPadding(Edge.Top, 5); - root.setPadding(Edge.Right, 5); - root.setPadding(Edge.Bottom, 5); - root.setBorder(Edge.Left, 10); - root.setBorder(Edge.Top, 10); - root.setBorder(Edge.Right, 10); - root.setBorder(Edge.Bottom, 10); - root.setWidth(100); - root.setHeight(100); - root.setBoxSizing(BoxSizing.ContentBox); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(130); - expect(root.getComputedHeight()).toBe(130); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(130); - expect(root.getComputedHeight()).toBe(130); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 5); + root.setPadding(Edge.Top, 5); + root.setPadding(Edge.Right, 5); + root.setPadding(Edge.Bottom, 5); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(130); + expect(root.getComputedHeight()).toBe(130); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(130); + expect(root.getComputedHeight()).toBe(130); }); test('box_sizing_border_box_simple', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 5); - root.setPadding(Edge.Top, 5); - root.setPadding(Edge.Right, 5); - root.setPadding(Edge.Bottom, 5); - root.setBorder(Edge.Left, 10); - root.setBorder(Edge.Top, 10); - root.setBorder(Edge.Right, 10); - root.setBorder(Edge.Bottom, 10); - root.setWidth(100); - root.setHeight(100); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 5); + root.setPadding(Edge.Top, 5); + root.setPadding(Edge.Right, 5); + root.setPadding(Edge.Bottom, 5); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); }); test('box_sizing_content_box_percent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 4); - root_child0.setPadding(Edge.Top, 4); - root_child0.setPadding(Edge.Right, 4); - root_child0.setPadding(Edge.Bottom, 4); - root_child0.setBorder(Edge.Left, 16); - root_child0.setBorder(Edge.Top, 16); - root_child0.setBorder(Edge.Right, 16); - root_child0.setBorder(Edge.Bottom, 16); - root_child0.setWidth("50%"); - root_child0.setHeight("25%"); - root_child0.setBoxSizing(BoxSizing.ContentBox); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(90); - expect(root_child0.getComputedHeight()).toBe(65); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(90); - expect(root_child0.getComputedHeight()).toBe(65); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 4); + root_child0.setPadding(Edge.Top, 4); + root_child0.setPadding(Edge.Right, 4); + root_child0.setPadding(Edge.Bottom, 4); + root_child0.setBorder(Edge.Left, 16); + root_child0.setBorder(Edge.Top, 16); + root_child0.setBorder(Edge.Right, 16); + root_child0.setBorder(Edge.Bottom, 16); + root_child0.setWidth("50%"); + root_child0.setHeight("25%"); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(65); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(65); }); test('box_sizing_border_box_percent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 4); - root_child0.setPadding(Edge.Top, 4); - root_child0.setPadding(Edge.Right, 4); - root_child0.setPadding(Edge.Bottom, 4); - root_child0.setBorder(Edge.Left, 16); - root_child0.setBorder(Edge.Top, 16); - root_child0.setBorder(Edge.Right, 16); - root_child0.setBorder(Edge.Bottom, 16); - root_child0.setWidth("50%"); - root_child0.setHeight("25%"); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 4); + root_child0.setPadding(Edge.Top, 4); + root_child0.setPadding(Edge.Right, 4); + root_child0.setPadding(Edge.Bottom, 4); + root_child0.setBorder(Edge.Left, 16); + root_child0.setBorder(Edge.Top, 16); + root_child0.setBorder(Edge.Right, 16); + root_child0.setBorder(Edge.Bottom, 16); + root_child0.setWidth("50%"); + root_child0.setHeight("25%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); }); test('box_sizing_content_box_absolute', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPadding(Edge.Left, 12); - root_child0.setPadding(Edge.Top, 12); - root_child0.setPadding(Edge.Right, 12); - root_child0.setPadding(Edge.Bottom, 12); - root_child0.setBorder(Edge.Left, 8); - root_child0.setBorder(Edge.Top, 8); - root_child0.setBorder(Edge.Right, 8); - root_child0.setBorder(Edge.Bottom, 8); - root_child0.setHeight("25%"); - root_child0.setBoxSizing(BoxSizing.ContentBox); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(65); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(65); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPadding(Edge.Left, 12); + root_child0.setPadding(Edge.Top, 12); + root_child0.setPadding(Edge.Right, 12); + root_child0.setPadding(Edge.Bottom, 12); + root_child0.setBorder(Edge.Left, 8); + root_child0.setBorder(Edge.Top, 8); + root_child0.setBorder(Edge.Right, 8); + root_child0.setBorder(Edge.Bottom, 8); + root_child0.setHeight("25%"); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(65); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(65); }); test('box_sizing_border_box_absolute', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPadding(Edge.Left, 12); - root_child0.setPadding(Edge.Top, 12); - root_child0.setPadding(Edge.Right, 12); - root_child0.setPadding(Edge.Bottom, 12); - root_child0.setBorder(Edge.Left, 8); - root_child0.setBorder(Edge.Top, 8); - root_child0.setBorder(Edge.Right, 8); - root_child0.setBorder(Edge.Bottom, 8); - root_child0.setHeight("25%"); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPadding(Edge.Left, 12); + root_child0.setPadding(Edge.Top, 12); + root_child0.setPadding(Edge.Right, 12); + root_child0.setPadding(Edge.Bottom, 12); + root_child0.setBorder(Edge.Left, 8); + root_child0.setBorder(Edge.Top, 8); + root_child0.setBorder(Edge.Right, 8); + root_child0.setBorder(Edge.Bottom, 8); + root_child0.setHeight("25%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); }); test('box_sizing_content_box_comtaining_block', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 12); - root.setPadding(Edge.Top, 12); - root.setPadding(Edge.Right, 12); - root.setPadding(Edge.Bottom, 12); - root.setBorder(Edge.Left, 8); - root.setBorder(Edge.Top, 8); - root.setBorder(Edge.Right, 8); - root.setBorder(Edge.Bottom, 8); - root.setWidth(100); - root.setHeight(100); - root.setBoxSizing(BoxSizing.ContentBox); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Static); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight("25%"); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(140); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(31); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(140); - expect(root.getComputedHeight()).toBe(140); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(31); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 12); + root.setPadding(Edge.Top, 12); + root.setPadding(Edge.Right, 12); + root.setPadding(Edge.Bottom, 12); + root.setBorder(Edge.Left, 8); + root.setBorder(Edge.Top, 8); + root.setBorder(Edge.Right, 8); + root.setBorder(Edge.Bottom, 8); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Static); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight("25%"); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(140); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(31); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(140); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(31); }); test('box_sizing_border_box_comtaining_block', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 12); - root.setPadding(Edge.Top, 12); - root.setPadding(Edge.Right, 12); - root.setPadding(Edge.Bottom, 12); - root.setBorder(Edge.Left, 8); - root.setBorder(Edge.Top, 8); - root.setBorder(Edge.Right, 8); - root.setBorder(Edge.Bottom, 8); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Static); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight("25%"); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(21); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(10); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(21); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 12); + root.setPadding(Edge.Top, 12); + root.setPadding(Edge.Right, 12); + root.setPadding(Edge.Bottom, 12); + root.setBorder(Edge.Left, 8); + root.setBorder(Edge.Top, 8); + root.setBorder(Edge.Right, 8); + root.setBorder(Edge.Bottom, 8); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Static); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight("25%"); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(21); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(21); }); test('box_sizing_content_box_padding_only', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 5); - root.setPadding(Edge.Top, 5); - root.setPadding(Edge.Right, 5); - root.setPadding(Edge.Bottom, 5); - root.setWidth(100); - root.setHeight(100); - root.setBoxSizing(BoxSizing.ContentBox); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(110); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(110); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 5); + root.setPadding(Edge.Top, 5); + root.setPadding(Edge.Right, 5); + root.setPadding(Edge.Bottom, 5); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(110); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(110); }); test('box_sizing_content_box_padding_only_percent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(150); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, "10%"); - root_child0.setPadding(Edge.Top, "10%"); - root_child0.setPadding(Edge.Right, "10%"); - root_child0.setPadding(Edge.Bottom, "10%"); - root_child0.setWidth(50); - root_child0.setHeight(75); - root_child0.setBoxSizing(BoxSizing.ContentBox); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(70); - expect(root_child0.getComputedHeight()).toBe(95); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(30); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(70); - expect(root_child0.getComputedHeight()).toBe(95); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(150); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, "10%"); + root_child0.setPadding(Edge.Top, "10%"); + root_child0.setPadding(Edge.Right, "10%"); + root_child0.setPadding(Edge.Bottom, "10%"); + root_child0.setWidth(50); + root_child0.setHeight(75); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(70); + expect(root_child0.getComputedHeight()).toBe(95); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(70); + expect(root_child0.getComputedHeight()).toBe(95); }); test('box_sizing_border_box_padding_only', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 5); - root.setPadding(Edge.Top, 5); - root.setPadding(Edge.Right, 5); - root.setPadding(Edge.Bottom, 5); - root.setWidth(100); - root.setHeight(100); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 5); + root.setPadding(Edge.Top, 5); + root.setPadding(Edge.Right, 5); + root.setPadding(Edge.Bottom, 5); + root.setWidth(100); + root.setHeight(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); }); test('box_sizing_border_box_padding_only_percent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(150); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, "10%"); - root_child0.setPadding(Edge.Top, "10%"); - root_child0.setPadding(Edge.Right, "10%"); - root_child0.setPadding(Edge.Bottom, "10%"); - root_child0.setWidth(50); - root_child0.setHeight(75); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(75); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(75); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(150); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, "10%"); + root_child0.setPadding(Edge.Top, "10%"); + root_child0.setPadding(Edge.Right, "10%"); + root_child0.setPadding(Edge.Bottom, "10%"); + root_child0.setWidth(50); + root_child0.setHeight(75); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(75); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(75); }); test('box_sizing_content_box_border_only', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 10); - root.setBorder(Edge.Top, 10); - root.setBorder(Edge.Right, 10); - root.setBorder(Edge.Bottom, 10); - root.setWidth(100); - root.setHeight(100); - root.setBoxSizing(BoxSizing.ContentBox); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(120); - expect(root.getComputedHeight()).toBe(120); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(120); - expect(root.getComputedHeight()).toBe(120); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); }); test('box_sizing_content_box_border_only_percent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("50%"); - root_child0.setBoxSizing(BoxSizing.ContentBox); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); }); test('box_sizing_border_box_border_only', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 10); - root.setBorder(Edge.Top, 10); - root.setBorder(Edge.Right, 10); - root.setBorder(Edge.Bottom, 10); - root.setWidth(100); - root.setHeight(100); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); }); test('box_sizing_border_box_border_only_percent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("50%"); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); }); test('box_sizing_content_box_no_padding_no_border', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - root.setBoxSizing(BoxSizing.ContentBox); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); }); test('box_sizing_border_box_no_padding_no_border', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); }); test('box_sizing_content_box_children', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 5); - root.setPadding(Edge.Top, 5); - root.setPadding(Edge.Right, 5); - root.setPadding(Edge.Bottom, 5); - root.setBorder(Edge.Left, 10); - root.setBorder(Edge.Top, 10); - root.setBorder(Edge.Right, 10); - root.setBorder(Edge.Bottom, 10); - root.setWidth(100); - root.setHeight(100); - root.setBoxSizing(BoxSizing.ContentBox); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(25); - root_child0.setHeight(25); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(25); - root_child1.setHeight(25); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(25); - root_child2.setHeight(25); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(25); - root_child3.setHeight(25); - root.insertChild(root_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(130); - expect(root.getComputedHeight()).toBe(130); - - expect(root_child0.getComputedLeft()).toBe(15); - expect(root_child0.getComputedTop()).toBe(15); - expect(root_child0.getComputedWidth()).toBe(25); - expect(root_child0.getComputedHeight()).toBe(25); - - expect(root_child1.getComputedLeft()).toBe(15); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child2.getComputedLeft()).toBe(15); - expect(root_child2.getComputedTop()).toBe(65); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(25); - - expect(root_child3.getComputedLeft()).toBe(15); - expect(root_child3.getComputedTop()).toBe(90); - expect(root_child3.getComputedWidth()).toBe(25); - expect(root_child3.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(130); - expect(root.getComputedHeight()).toBe(130); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(15); - expect(root_child0.getComputedWidth()).toBe(25); - expect(root_child0.getComputedHeight()).toBe(25); - - expect(root_child1.getComputedLeft()).toBe(90); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child2.getComputedLeft()).toBe(90); - expect(root_child2.getComputedTop()).toBe(65); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(25); - - expect(root_child3.getComputedLeft()).toBe(90); - expect(root_child3.getComputedTop()).toBe(90); - expect(root_child3.getComputedWidth()).toBe(25); - expect(root_child3.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 5); + root.setPadding(Edge.Top, 5); + root.setPadding(Edge.Right, 5); + root.setPadding(Edge.Bottom, 5); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(25); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(25); + root_child3.setHeight(25); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(130); + expect(root.getComputedHeight()).toBe(130); + + expect(root_child0.getComputedLeft()).toBe(15); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(15); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(15); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(15); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(130); + expect(root.getComputedHeight()).toBe(130); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(90); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); }); test('box_sizing_border_box_children', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 5); - root.setPadding(Edge.Top, 5); - root.setPadding(Edge.Right, 5); - root.setPadding(Edge.Bottom, 5); - root.setBorder(Edge.Left, 10); - root.setBorder(Edge.Top, 10); - root.setBorder(Edge.Right, 10); - root.setBorder(Edge.Bottom, 10); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(25); - root_child0.setHeight(25); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(25); - root_child1.setHeight(25); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(25); - root_child2.setHeight(25); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(25); - root_child3.setHeight(25); - root.insertChild(root_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(15); - expect(root_child0.getComputedTop()).toBe(15); - expect(root_child0.getComputedWidth()).toBe(25); - expect(root_child0.getComputedHeight()).toBe(25); - - expect(root_child1.getComputedLeft()).toBe(15); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child2.getComputedLeft()).toBe(15); - expect(root_child2.getComputedTop()).toBe(65); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(25); - - expect(root_child3.getComputedLeft()).toBe(15); - expect(root_child3.getComputedTop()).toBe(90); - expect(root_child3.getComputedWidth()).toBe(25); - expect(root_child3.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(15); - expect(root_child0.getComputedWidth()).toBe(25); - expect(root_child0.getComputedHeight()).toBe(25); - - expect(root_child1.getComputedLeft()).toBe(60); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(65); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(25); - - expect(root_child3.getComputedLeft()).toBe(60); - expect(root_child3.getComputedTop()).toBe(90); - expect(root_child3.getComputedWidth()).toBe(25); - expect(root_child3.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 5); + root.setPadding(Edge.Top, 5); + root.setPadding(Edge.Right, 5); + root.setPadding(Edge.Bottom, 5); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(25); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(25); + root_child3.setHeight(25); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(15); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(15); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(15); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(15); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(60); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); }); test('box_sizing_content_box_siblings', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(25); - root_child0.setHeight(25); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setPadding(Edge.Left, 10); - root_child1.setPadding(Edge.Top, 10); - root_child1.setPadding(Edge.Right, 10); - root_child1.setPadding(Edge.Bottom, 10); - root_child1.setBorder(Edge.Left, 10); - root_child1.setBorder(Edge.Top, 10); - root_child1.setBorder(Edge.Right, 10); - root_child1.setBorder(Edge.Bottom, 10); - root_child1.setWidth(25); - root_child1.setHeight(25); - root_child1.setBoxSizing(BoxSizing.ContentBox); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(25); - root_child2.setHeight(25); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(25); - root_child3.setHeight(25); - root.insertChild(root_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(25); - expect(root_child0.getComputedHeight()).toBe(25); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(25); - expect(root_child1.getComputedWidth()).toBe(65); - expect(root_child1.getComputedHeight()).toBe(65); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(90); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(25); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(115); - expect(root_child3.getComputedWidth()).toBe(25); - expect(root_child3.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(25); - expect(root_child0.getComputedHeight()).toBe(25); - - expect(root_child1.getComputedLeft()).toBe(35); - expect(root_child1.getComputedTop()).toBe(25); - expect(root_child1.getComputedWidth()).toBe(65); - expect(root_child1.getComputedHeight()).toBe(65); - - expect(root_child2.getComputedLeft()).toBe(75); - expect(root_child2.getComputedTop()).toBe(90); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(25); - - expect(root_child3.getComputedLeft()).toBe(75); - expect(root_child3.getComputedTop()).toBe(115); - expect(root_child3.getComputedWidth()).toBe(25); - expect(root_child3.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(25); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPadding(Edge.Left, 10); + root_child1.setPadding(Edge.Top, 10); + root_child1.setPadding(Edge.Right, 10); + root_child1.setPadding(Edge.Bottom, 10); + root_child1.setBorder(Edge.Left, 10); + root_child1.setBorder(Edge.Top, 10); + root_child1.setBorder(Edge.Right, 10); + root_child1.setBorder(Edge.Bottom, 10); + root_child1.setWidth(25); + root_child1.setHeight(25); + root_child1.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(25); + root_child3.setHeight(25); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(25); + expect(root_child1.getComputedWidth()).toBe(65); + expect(root_child1.getComputedHeight()).toBe(65); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(90); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(115); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(35); + expect(root_child1.getComputedTop()).toBe(25); + expect(root_child1.getComputedWidth()).toBe(65); + expect(root_child1.getComputedHeight()).toBe(65); + + expect(root_child2.getComputedLeft()).toBe(75); + expect(root_child2.getComputedTop()).toBe(90); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(75); + expect(root_child3.getComputedTop()).toBe(115); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); }); test('box_sizing_border_box_siblings', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(25); - root_child0.setHeight(25); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setPadding(Edge.Left, 10); - root_child1.setPadding(Edge.Top, 10); - root_child1.setPadding(Edge.Right, 10); - root_child1.setPadding(Edge.Bottom, 10); - root_child1.setBorder(Edge.Left, 10); - root_child1.setBorder(Edge.Top, 10); - root_child1.setBorder(Edge.Right, 10); - root_child1.setBorder(Edge.Bottom, 10); - root_child1.setWidth(25); - root_child1.setHeight(25); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(25); - root_child2.setHeight(25); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(25); - root_child3.setHeight(25); - root.insertChild(root_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(25); - expect(root_child0.getComputedHeight()).toBe(25); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(25); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(40); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(65); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(25); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(90); - expect(root_child3.getComputedWidth()).toBe(25); - expect(root_child3.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(25); - expect(root_child0.getComputedHeight()).toBe(25); - - expect(root_child1.getComputedLeft()).toBe(60); - expect(root_child1.getComputedTop()).toBe(25); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(40); - - expect(root_child2.getComputedLeft()).toBe(75); - expect(root_child2.getComputedTop()).toBe(65); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(25); - - expect(root_child3.getComputedLeft()).toBe(75); - expect(root_child3.getComputedTop()).toBe(90); - expect(root_child3.getComputedWidth()).toBe(25); - expect(root_child3.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(25); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPadding(Edge.Left, 10); + root_child1.setPadding(Edge.Top, 10); + root_child1.setPadding(Edge.Right, 10); + root_child1.setPadding(Edge.Bottom, 10); + root_child1.setBorder(Edge.Left, 10); + root_child1.setBorder(Edge.Top, 10); + root_child1.setBorder(Edge.Right, 10); + root_child1.setBorder(Edge.Bottom, 10); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(25); + root_child3.setHeight(25); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(25); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(25); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(75); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(75); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); }); test('box_sizing_content_box_max_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 5); - root_child0.setPadding(Edge.Top, 5); - root_child0.setPadding(Edge.Right, 5); - root_child0.setPadding(Edge.Bottom, 5); - root_child0.setBorder(Edge.Left, 15); - root_child0.setBorder(Edge.Top, 15); - root_child0.setBorder(Edge.Right, 15); - root_child0.setBorder(Edge.Bottom, 15); - root_child0.setMaxWidth(50); - root_child0.setHeight(25); - root_child0.setBoxSizing(BoxSizing.ContentBox); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(25); - root_child1.setHeight(25); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(90); - expect(root_child0.getComputedHeight()).toBe(65); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(65); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(90); - expect(root_child0.getComputedHeight()).toBe(65); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(65); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setMaxWidth(50); + root_child0.setHeight(25); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); }); test('box_sizing_border_box_max_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 5); - root_child0.setPadding(Edge.Top, 5); - root_child0.setPadding(Edge.Right, 5); - root_child0.setPadding(Edge.Bottom, 5); - root_child0.setBorder(Edge.Left, 15); - root_child0.setBorder(Edge.Top, 15); - root_child0.setBorder(Edge.Right, 15); - root_child0.setBorder(Edge.Bottom, 15); - root_child0.setMaxWidth(50); - root_child0.setHeight(25); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(25); - root_child1.setHeight(25); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(40); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(40); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setMaxWidth(50); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); }); test('box_sizing_content_box_max_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 5); - root_child0.setPadding(Edge.Top, 5); - root_child0.setPadding(Edge.Right, 5); - root_child0.setPadding(Edge.Bottom, 5); - root_child0.setBorder(Edge.Left, 15); - root_child0.setBorder(Edge.Top, 15); - root_child0.setBorder(Edge.Right, 15); - root_child0.setBorder(Edge.Bottom, 15); - root_child0.setWidth(50); - root_child0.setMaxHeight(50); - root_child0.setBoxSizing(BoxSizing.ContentBox); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(25); - root_child1.setHeight(25); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(90); - expect(root_child0.getComputedHeight()).toBe(40); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(90); - expect(root_child0.getComputedHeight()).toBe(40); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setWidth(50); + root_child0.setMaxHeight(50); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); }); test('box_sizing_border_box_max_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 5); - root_child0.setPadding(Edge.Top, 5); - root_child0.setPadding(Edge.Right, 5); - root_child0.setPadding(Edge.Bottom, 5); - root_child0.setBorder(Edge.Left, 15); - root_child0.setBorder(Edge.Top, 15); - root_child0.setBorder(Edge.Right, 15); - root_child0.setBorder(Edge.Bottom, 15); - root_child0.setWidth(50); - root_child0.setMaxHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(25); - root_child1.setHeight(25); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(40); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(40); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setWidth(50); + root_child0.setMaxHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); }); test('box_sizing_content_box_min_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 5); - root_child0.setPadding(Edge.Top, 5); - root_child0.setPadding(Edge.Right, 5); - root_child0.setPadding(Edge.Bottom, 5); - root_child0.setBorder(Edge.Left, 15); - root_child0.setBorder(Edge.Top, 15); - root_child0.setBorder(Edge.Right, 15); - root_child0.setBorder(Edge.Bottom, 15); - root_child0.setMinWidth(50); - root_child0.setHeight(25); - root_child0.setBoxSizing(BoxSizing.ContentBox); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(25); - root_child1.setHeight(25); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(65); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(65); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(65); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(65); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setMinWidth(50); + root_child0.setHeight(25); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); }); test('box_sizing_border_box_min_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 5); - root_child0.setPadding(Edge.Top, 5); - root_child0.setPadding(Edge.Right, 5); - root_child0.setPadding(Edge.Bottom, 5); - root_child0.setBorder(Edge.Left, 15); - root_child0.setBorder(Edge.Top, 15); - root_child0.setBorder(Edge.Right, 15); - root_child0.setBorder(Edge.Bottom, 15); - root_child0.setMinWidth(50); - root_child0.setHeight(25); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(25); - root_child1.setHeight(25); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(40); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(40); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setMinWidth(50); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); }); test('box_sizing_content_box_min_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 5); - root_child0.setPadding(Edge.Top, 5); - root_child0.setPadding(Edge.Right, 5); - root_child0.setPadding(Edge.Bottom, 5); - root_child0.setBorder(Edge.Left, 15); - root_child0.setBorder(Edge.Top, 15); - root_child0.setBorder(Edge.Right, 15); - root_child0.setBorder(Edge.Bottom, 15); - root_child0.setWidth(50); - root_child0.setMinHeight(50); - root_child0.setBoxSizing(BoxSizing.ContentBox); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(25); - root_child1.setHeight(25); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(90); - expect(root_child0.getComputedHeight()).toBe(90); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(90); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(90); - expect(root_child0.getComputedHeight()).toBe(90); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(90); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setWidth(50); + root_child0.setMinHeight(50); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(90); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(90); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); }); test('box_sizing_border_box_min_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 5); - root_child0.setPadding(Edge.Top, 5); - root_child0.setPadding(Edge.Right, 5); - root_child0.setPadding(Edge.Bottom, 5); - root_child0.setBorder(Edge.Left, 15); - root_child0.setBorder(Edge.Top, 15); - root_child0.setBorder(Edge.Right, 15); - root_child0.setBorder(Edge.Bottom, 15); - root_child0.setWidth(50); - root_child0.setMinHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(25); - root_child1.setHeight(25); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setWidth(50); + root_child0.setMinHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); }); test('box_sizing_content_box_no_height_no_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 2); - root_child0.setPadding(Edge.Right, 2); - root_child0.setPadding(Edge.Bottom, 2); - root_child0.setBorder(Edge.Left, 7); - root_child0.setBorder(Edge.Top, 7); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 7); - root_child0.setBoxSizing(BoxSizing.ContentBox); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(18); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(18); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 2); + root_child0.setPadding(Edge.Right, 2); + root_child0.setPadding(Edge.Bottom, 2); + root_child0.setBorder(Edge.Left, 7); + root_child0.setBorder(Edge.Top, 7); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 7); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(18); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(18); }); test('box_sizing_border_box_no_height_no_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 2); - root_child0.setPadding(Edge.Right, 2); - root_child0.setPadding(Edge.Bottom, 2); - root_child0.setBorder(Edge.Left, 7); - root_child0.setBorder(Edge.Top, 7); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 7); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(18); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(18); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 2); + root_child0.setPadding(Edge.Right, 2); + root_child0.setPadding(Edge.Bottom, 2); + root_child0.setBorder(Edge.Left, 7); + root_child0.setBorder(Edge.Top, 7); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 7); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(18); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(18); }); test('box_sizing_content_box_nested', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 15); - root.setPadding(Edge.Top, 15); - root.setPadding(Edge.Right, 15); - root.setPadding(Edge.Bottom, 15); - root.setBorder(Edge.Left, 3); - root.setBorder(Edge.Top, 3); - root.setBorder(Edge.Right, 3); - root.setBorder(Edge.Bottom, 3); - root.setWidth(100); - root.setHeight(100); - root.setBoxSizing(BoxSizing.ContentBox); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 2); - root_child0.setPadding(Edge.Right, 2); - root_child0.setPadding(Edge.Bottom, 2); - root_child0.setBorder(Edge.Left, 7); - root_child0.setBorder(Edge.Top, 7); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 7); - root_child0.setWidth(20); - root_child0.setHeight(20); - root_child0.setBoxSizing(BoxSizing.ContentBox); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 1); - root_child0_child0.setPadding(Edge.Right, 1); - root_child0_child0.setPadding(Edge.Bottom, 1); - root_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0.setBorder(Edge.Top, 2); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 2); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(5); - root_child0_child0.setBoxSizing(BoxSizing.ContentBox); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(136); - expect(root.getComputedHeight()).toBe(136); - - expect(root_child0.getComputedLeft()).toBe(18); - expect(root_child0.getComputedTop()).toBe(18); - expect(root_child0.getComputedWidth()).toBe(38); - expect(root_child0.getComputedHeight()).toBe(38); - - expect(root_child0_child0.getComputedLeft()).toBe(9); - expect(root_child0_child0.getComputedTop()).toBe(9); - expect(root_child0_child0.getComputedWidth()).toBe(16); - expect(root_child0_child0.getComputedHeight()).toBe(11); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(136); - expect(root.getComputedHeight()).toBe(136); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(18); - expect(root_child0.getComputedWidth()).toBe(38); - expect(root_child0.getComputedHeight()).toBe(38); - - expect(root_child0_child0.getComputedLeft()).toBe(13); - expect(root_child0_child0.getComputedTop()).toBe(9); - expect(root_child0_child0.getComputedWidth()).toBe(16); - expect(root_child0_child0.getComputedHeight()).toBe(11); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 15); + root.setPadding(Edge.Top, 15); + root.setPadding(Edge.Right, 15); + root.setPadding(Edge.Bottom, 15); + root.setBorder(Edge.Left, 3); + root.setBorder(Edge.Top, 3); + root.setBorder(Edge.Right, 3); + root.setBorder(Edge.Bottom, 3); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 2); + root_child0.setPadding(Edge.Right, 2); + root_child0.setPadding(Edge.Bottom, 2); + root_child0.setBorder(Edge.Left, 7); + root_child0.setBorder(Edge.Top, 7); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 7); + root_child0.setWidth(20); + root_child0.setHeight(20); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 1); + root_child0_child0.setPadding(Edge.Right, 1); + root_child0_child0.setPadding(Edge.Bottom, 1); + root_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0.setBorder(Edge.Top, 2); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 2); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(5); + root_child0_child0.setBoxSizing(BoxSizing.ContentBox); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(136); + expect(root.getComputedHeight()).toBe(136); + + expect(root_child0.getComputedLeft()).toBe(18); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(38); + expect(root_child0.getComputedHeight()).toBe(38); + + expect(root_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0.getComputedWidth()).toBe(16); + expect(root_child0_child0.getComputedHeight()).toBe(11); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(136); + expect(root.getComputedHeight()).toBe(136); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(38); + expect(root_child0.getComputedHeight()).toBe(38); + + expect(root_child0_child0.getComputedLeft()).toBe(13); + expect(root_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0.getComputedWidth()).toBe(16); + expect(root_child0_child0.getComputedHeight()).toBe(11); }); test('box_sizing_border_box_nested', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 15); - root.setPadding(Edge.Top, 15); - root.setPadding(Edge.Right, 15); - root.setPadding(Edge.Bottom, 15); - root.setBorder(Edge.Left, 3); - root.setBorder(Edge.Top, 3); - root.setBorder(Edge.Right, 3); - root.setBorder(Edge.Bottom, 3); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 2); - root_child0.setPadding(Edge.Right, 2); - root_child0.setPadding(Edge.Bottom, 2); - root_child0.setBorder(Edge.Left, 7); - root_child0.setBorder(Edge.Top, 7); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 7); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 1); - root_child0_child0.setPadding(Edge.Right, 1); - root_child0_child0.setPadding(Edge.Bottom, 1); - root_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0.setBorder(Edge.Top, 2); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 2); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(5); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(18); - expect(root_child0.getComputedTop()).toBe(18); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(9); - expect(root_child0_child0.getComputedTop()).toBe(9); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(6); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(62); - expect(root_child0.getComputedTop()).toBe(18); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(1); - expect(root_child0_child0.getComputedTop()).toBe(9); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(6); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 15); + root.setPadding(Edge.Top, 15); + root.setPadding(Edge.Right, 15); + root.setPadding(Edge.Bottom, 15); + root.setBorder(Edge.Left, 3); + root.setBorder(Edge.Top, 3); + root.setBorder(Edge.Right, 3); + root.setBorder(Edge.Bottom, 3); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 2); + root_child0.setPadding(Edge.Right, 2); + root_child0.setPadding(Edge.Bottom, 2); + root_child0.setBorder(Edge.Left, 7); + root_child0.setBorder(Edge.Top, 7); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 7); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 1); + root_child0_child0.setPadding(Edge.Right, 1); + root_child0_child0.setPadding(Edge.Bottom, 1); + root_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0.setBorder(Edge.Top, 2); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 2); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(5); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(18); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(6); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(62); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(1); + expect(root_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(6); }); test('box_sizing_content_box_nested_alternating', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 3); - root.setPadding(Edge.Top, 3); - root.setPadding(Edge.Right, 3); - root.setPadding(Edge.Bottom, 3); - root.setBorder(Edge.Left, 2); - root.setBorder(Edge.Top, 2); - root.setBorder(Edge.Right, 2); - root.setBorder(Edge.Bottom, 2); - root.setWidth(100); - root.setHeight(100); - root.setBoxSizing(BoxSizing.ContentBox); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 8); - root_child0.setPadding(Edge.Top, 8); - root_child0.setPadding(Edge.Right, 8); - root_child0.setPadding(Edge.Bottom, 8); - root_child0.setBorder(Edge.Left, 2); - root_child0.setBorder(Edge.Top, 2); - root_child0.setBorder(Edge.Right, 2); - root_child0.setBorder(Edge.Bottom, 2); - root_child0.setWidth(40); - root_child0.setHeight(40); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPadding(Edge.Left, 3); - root_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0.setPadding(Edge.Right, 3); - root_child0_child0.setPadding(Edge.Bottom, 3); - root_child0_child0.setBorder(Edge.Left, 6); - root_child0_child0.setBorder(Edge.Top, 6); - root_child0_child0.setBorder(Edge.Right, 6); - root_child0_child0.setBorder(Edge.Bottom, 6); - root_child0_child0.setWidth(20); - root_child0_child0.setHeight(25); - root_child0_child0.setBoxSizing(BoxSizing.ContentBox); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0_child0.setPadding(Edge.Top, 1); - root_child0_child0_child0.setPadding(Edge.Right, 1); - root_child0_child0_child0.setPadding(Edge.Bottom, 1); - root_child0_child0_child0.setBorder(Edge.Left, 1); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 1); - root_child0_child0_child0.setBorder(Edge.Bottom, 1); - root_child0_child0_child0.setWidth(10); - root_child0_child0_child0.setHeight(5); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(110); - - expect(root_child0.getComputedLeft()).toBe(5); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(40); - - expect(root_child0_child0.getComputedLeft()).toBe(10); - expect(root_child0_child0.getComputedTop()).toBe(10); - expect(root_child0_child0.getComputedWidth()).toBe(38); - expect(root_child0_child0.getComputedHeight()).toBe(43); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(9); - expect(root_child0_child0_child0.getComputedTop()).toBe(9); - expect(root_child0_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0_child0.getComputedHeight()).toBe(5); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(110); - expect(root.getComputedHeight()).toBe(110); - - expect(root_child0.getComputedLeft()).toBe(65); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(40); - - expect(root_child0_child0.getComputedLeft()).toBe(-8); - expect(root_child0_child0.getComputedTop()).toBe(10); - expect(root_child0_child0.getComputedWidth()).toBe(38); - expect(root_child0_child0.getComputedHeight()).toBe(43); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(19); - expect(root_child0_child0_child0.getComputedTop()).toBe(9); - expect(root_child0_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0_child0.getComputedHeight()).toBe(5); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 3); + root.setPadding(Edge.Top, 3); + root.setPadding(Edge.Right, 3); + root.setPadding(Edge.Bottom, 3); + root.setBorder(Edge.Left, 2); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 2); + root.setBorder(Edge.Bottom, 2); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 8); + root_child0.setPadding(Edge.Top, 8); + root_child0.setPadding(Edge.Right, 8); + root_child0.setPadding(Edge.Bottom, 8); + root_child0.setBorder(Edge.Left, 2); + root_child0.setBorder(Edge.Top, 2); + root_child0.setBorder(Edge.Right, 2); + root_child0.setBorder(Edge.Bottom, 2); + root_child0.setWidth(40); + root_child0.setHeight(40); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPadding(Edge.Left, 3); + root_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0.setPadding(Edge.Right, 3); + root_child0_child0.setPadding(Edge.Bottom, 3); + root_child0_child0.setBorder(Edge.Left, 6); + root_child0_child0.setBorder(Edge.Top, 6); + root_child0_child0.setBorder(Edge.Right, 6); + root_child0_child0.setBorder(Edge.Bottom, 6); + root_child0_child0.setWidth(20); + root_child0_child0.setHeight(25); + root_child0_child0.setBoxSizing(BoxSizing.ContentBox); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0_child0.setPadding(Edge.Top, 1); + root_child0_child0_child0.setPadding(Edge.Right, 1); + root_child0_child0_child0.setPadding(Edge.Bottom, 1); + root_child0_child0_child0.setBorder(Edge.Left, 1); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 1); + root_child0_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0_child0.setWidth(10); + root_child0_child0_child0.setHeight(5); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(110); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(38); + expect(root_child0_child0.getComputedHeight()).toBe(43); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0_child0.getComputedHeight()).toBe(5); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(110); + + expect(root_child0.getComputedLeft()).toBe(65); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0.getComputedLeft()).toBe(-8); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(38); + expect(root_child0_child0.getComputedHeight()).toBe(43); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(19); + expect(root_child0_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0_child0.getComputedHeight()).toBe(5); }); test('box_sizing_border_box_nested_alternating', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 3); - root.setPadding(Edge.Top, 3); - root.setPadding(Edge.Right, 3); - root.setPadding(Edge.Bottom, 3); - root.setBorder(Edge.Left, 2); - root.setBorder(Edge.Top, 2); - root.setBorder(Edge.Right, 2); - root.setBorder(Edge.Bottom, 2); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 8); - root_child0.setPadding(Edge.Top, 8); - root_child0.setPadding(Edge.Right, 8); - root_child0.setPadding(Edge.Bottom, 8); - root_child0.setBorder(Edge.Left, 2); - root_child0.setBorder(Edge.Top, 2); - root_child0.setBorder(Edge.Right, 2); - root_child0.setBorder(Edge.Bottom, 2); - root_child0.setWidth(40); - root_child0.setHeight(40); - root_child0.setBoxSizing(BoxSizing.ContentBox); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPadding(Edge.Left, 3); - root_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0.setPadding(Edge.Right, 3); - root_child0_child0.setPadding(Edge.Bottom, 3); - root_child0_child0.setBorder(Edge.Left, 6); - root_child0_child0.setBorder(Edge.Top, 6); - root_child0_child0.setBorder(Edge.Right, 6); - root_child0_child0.setBorder(Edge.Bottom, 6); - root_child0_child0.setWidth(20); - root_child0_child0.setHeight(25); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0_child0.setPadding(Edge.Top, 1); - root_child0_child0_child0.setPadding(Edge.Right, 1); - root_child0_child0_child0.setPadding(Edge.Bottom, 1); - root_child0_child0_child0.setBorder(Edge.Left, 1); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 1); - root_child0_child0_child0.setBorder(Edge.Bottom, 1); - root_child0_child0_child0.setWidth(10); - root_child0_child0_child0.setHeight(5); - root_child0_child0_child0.setBoxSizing(BoxSizing.ContentBox); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(5); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(60); - - expect(root_child0_child0.getComputedLeft()).toBe(10); - expect(root_child0_child0.getComputedTop()).toBe(10); - expect(root_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0.getComputedHeight()).toBe(25); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(9); - expect(root_child0_child0_child0.getComputedTop()).toBe(9); - expect(root_child0_child0_child0.getComputedWidth()).toBe(14); - expect(root_child0_child0_child0.getComputedHeight()).toBe(9); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(35); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(60); - - expect(root_child0_child0.getComputedLeft()).toBe(30); - expect(root_child0_child0.getComputedTop()).toBe(10); - expect(root_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0.getComputedHeight()).toBe(25); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-3); - expect(root_child0_child0_child0.getComputedTop()).toBe(9); - expect(root_child0_child0_child0.getComputedWidth()).toBe(14); - expect(root_child0_child0_child0.getComputedHeight()).toBe(9); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 3); + root.setPadding(Edge.Top, 3); + root.setPadding(Edge.Right, 3); + root.setPadding(Edge.Bottom, 3); + root.setBorder(Edge.Left, 2); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 2); + root.setBorder(Edge.Bottom, 2); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 8); + root_child0.setPadding(Edge.Top, 8); + root_child0.setPadding(Edge.Right, 8); + root_child0.setPadding(Edge.Bottom, 8); + root_child0.setBorder(Edge.Left, 2); + root_child0.setBorder(Edge.Top, 2); + root_child0.setBorder(Edge.Right, 2); + root_child0.setBorder(Edge.Bottom, 2); + root_child0.setWidth(40); + root_child0.setHeight(40); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPadding(Edge.Left, 3); + root_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0.setPadding(Edge.Right, 3); + root_child0_child0.setPadding(Edge.Bottom, 3); + root_child0_child0.setBorder(Edge.Left, 6); + root_child0_child0.setBorder(Edge.Top, 6); + root_child0_child0.setBorder(Edge.Right, 6); + root_child0_child0.setBorder(Edge.Bottom, 6); + root_child0_child0.setWidth(20); + root_child0_child0.setHeight(25); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0_child0.setPadding(Edge.Top, 1); + root_child0_child0_child0.setPadding(Edge.Right, 1); + root_child0_child0_child0.setPadding(Edge.Bottom, 1); + root_child0_child0_child0.setBorder(Edge.Left, 1); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 1); + root_child0_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0_child0.setWidth(10); + root_child0_child0_child0.setHeight(5); + root_child0_child0_child0.setBoxSizing(BoxSizing.ContentBox); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(25); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0_child0.getComputedWidth()).toBe(14); + expect(root_child0_child0_child0.getComputedHeight()).toBe(9); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(35); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child0_child0.getComputedLeft()).toBe(30); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(25); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-3); + expect(root_child0_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0_child0.getComputedWidth()).toBe(14); + expect(root_child0_child0_child0.getComputedHeight()).toBe(9); }); test.skip('box_sizing_content_box_flex_basis_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexBasis(50); - root_child0.setPadding(Edge.Left, 5); - root_child0.setPadding(Edge.Top, 5); - root_child0.setPadding(Edge.Right, 5); - root_child0.setPadding(Edge.Bottom, 5); - root_child0.setBorder(Edge.Left, 10); - root_child0.setBorder(Edge.Top, 10); - root_child0.setBorder(Edge.Right, 10); - root_child0.setBorder(Edge.Bottom, 10); - root_child0.setHeight(25); - root_child0.setBoxSizing(BoxSizing.ContentBox); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(80); - expect(root_child0.getComputedHeight()).toBe(55); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(80); - expect(root_child0.getComputedHeight()).toBe(55); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexBasis(50); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 10); + root_child0.setBorder(Edge.Top, 10); + root_child0.setBorder(Edge.Right, 10); + root_child0.setBorder(Edge.Bottom, 10); + root_child0.setHeight(25); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(55); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(55); }); test('box_sizing_border_box_flex_basis_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexBasis(50); - root_child0.setPadding(Edge.Left, 5); - root_child0.setPadding(Edge.Top, 5); - root_child0.setPadding(Edge.Right, 5); - root_child0.setPadding(Edge.Bottom, 5); - root_child0.setBorder(Edge.Left, 10); - root_child0.setBorder(Edge.Top, 10); - root_child0.setBorder(Edge.Right, 10); - root_child0.setBorder(Edge.Bottom, 10); - root_child0.setHeight(25); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(30); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(30); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexBasis(50); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 10); + root_child0.setBorder(Edge.Top, 10); + root_child0.setBorder(Edge.Right, 10); + root_child0.setBorder(Edge.Bottom, 10); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(30); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(30); }); test.skip('box_sizing_content_box_flex_basis_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexBasis(50); - root_child0.setPadding(Edge.Left, 5); - root_child0.setPadding(Edge.Top, 5); - root_child0.setPadding(Edge.Right, 5); - root_child0.setPadding(Edge.Bottom, 5); - root_child0.setBorder(Edge.Left, 10); - root_child0.setBorder(Edge.Top, 10); - root_child0.setBorder(Edge.Right, 10); - root_child0.setBorder(Edge.Bottom, 10); - root_child0.setHeight(25); - root_child0.setBoxSizing(BoxSizing.ContentBox); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(80); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(80); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexBasis(50); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 10); + root_child0.setBorder(Edge.Top, 10); + root_child0.setBorder(Edge.Right, 10); + root_child0.setBorder(Edge.Bottom, 10); + root_child0.setHeight(25); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); }); test('box_sizing_border_box_flex_basis_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexBasis(50); - root_child0.setPadding(Edge.Left, 5); - root_child0.setPadding(Edge.Top, 5); - root_child0.setPadding(Edge.Right, 5); - root_child0.setPadding(Edge.Bottom, 5); - root_child0.setBorder(Edge.Left, 10); - root_child0.setBorder(Edge.Top, 10); - root_child0.setBorder(Edge.Right, 10); - root_child0.setBorder(Edge.Bottom, 10); - root_child0.setHeight(25); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexBasis(50); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 10); + root_child0.setBorder(Edge.Top, 10); + root_child0.setBorder(Edge.Right, 10); + root_child0.setBorder(Edge.Bottom, 10); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); }); test('box_sizing_content_box_padding_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Start, 5); - root.setWidth(100); - root.setHeight(100); - root.setBoxSizing(BoxSizing.ContentBox); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(105); - expect(root.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(105); - expect(root.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Start, 5); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); }); test('box_sizing_border_box_padding_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Start, 5); - root.setWidth(100); - root.setHeight(100); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Start, 5); + root.setWidth(100); + root.setHeight(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); }); test('box_sizing_content_box_padding_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.End, 5); - root.setWidth(100); - root.setHeight(100); - root.setBoxSizing(BoxSizing.ContentBox); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(105); - expect(root.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(105); - expect(root.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.End, 5); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); }); test('box_sizing_border_box_padding_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.End, 5); - root.setWidth(100); - root.setHeight(100); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.End, 5); + root.setWidth(100); + root.setHeight(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); }); test('box_sizing_content_box_border_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Start, 5); - root.setWidth(100); - root.setHeight(100); - root.setBoxSizing(BoxSizing.ContentBox); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(105); - expect(root.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(105); - expect(root.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Start, 5); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); }); test('box_sizing_border_box_border_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Start, 5); - root.setWidth(100); - root.setHeight(100); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Start, 5); + root.setWidth(100); + root.setHeight(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); }); test('box_sizing_content_box_border_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.End, 5); - root.setWidth(100); - root.setHeight(100); - root.setBoxSizing(BoxSizing.ContentBox); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(105); - expect(root.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(105); - expect(root.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.End, 5); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); }); test('box_sizing_border_box_border_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.End, 5); - root.setWidth(100); - root.setHeight(100); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.End, 5); + root.setWidth(100); + root.setHeight(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); }); diff --git a/javascript/tests/generated/YGDimensionTest.test.ts b/javascript/tests/generated/YGDimensionTest.test.ts index 39c140df0e..46fef2c747 100644 --- a/javascript/tests/generated/YGDimensionTest.test.ts +++ b/javascript/tests/generated/YGDimensionTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<719c8f3b9fea672881a47f593f4aabd0>> + * @generated SignedSource<<5bec683aa77337211a474f8251565a53>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGDimensionTest.html */ @@ -30,100 +30,82 @@ import { test('wrap_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); }); test('wrap_grandchild', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); }); diff --git a/javascript/tests/generated/YGDisplayContentsTest.test.ts b/javascript/tests/generated/YGDisplayContentsTest.test.ts index e68784601f..750bc34d98 100644 --- a/javascript/tests/generated/YGDisplayContentsTest.test.ts +++ b/javascript/tests/generated/YGDisplayContentsTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<64d58fa2d33230f4eafc9ecbb6012a0d>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGDisplayContentsTest.html */ @@ -30,80 +30,70 @@ import { test('test1', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setDisplay(Display.Contents); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0_child0.setFlexBasis("0%"); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setFlexGrow(1); - root_child0_child1.setFlexShrink(1); - root_child0_child1.setFlexBasis("0%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(50); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setFlexGrow(1); + root_child0_child1.setFlexShrink(1); + root_child0_child1.setFlexBasis("0%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); }); diff --git a/javascript/tests/generated/YGDisplayTest.test.ts b/javascript/tests/generated/YGDisplayTest.test.ts index 9c6cd8d773..d92b8479ce 100644 --- a/javascript/tests/generated/YGDisplayTest.test.ts +++ b/javascript/tests/generated/YGDisplayTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGDisplayTest.html */ @@ -30,1068 +30,942 @@ import { test('display_none', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setDisplay(Display.None); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setDisplay(Display.None); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); }); test('display_none_fixed_size', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root_child1.setHeight(20); - root_child1.setDisplay(Display.None); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root_child1.setHeight(20); + root_child1.setDisplay(Display.None); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); }); test('display_none_with_margin', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 10); - root_child0.setMargin(Edge.Top, 10); - root_child0.setMargin(Edge.Right, 10); - root_child0.setMargin(Edge.Bottom, 10); - root_child0.setWidth(20); - root_child0.setHeight(20); - root_child0.setDisplay(Display.None); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 10); + root_child0.setMargin(Edge.Top, 10); + root_child0.setMargin(Edge.Right, 10); + root_child0.setMargin(Edge.Bottom, 10); + root_child0.setWidth(20); + root_child0.setHeight(20); + root_child0.setDisplay(Display.None); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); }); test('display_none_with_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis("0%"); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexShrink(1); - root_child1.setFlexBasis("0%"); - root_child1.setDisplay(Display.None); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setFlexGrow(1); - root_child1_child0.setFlexShrink(1); - root_child1_child0.setFlexBasis("0%"); - root_child1_child0.setWidth(20); - root_child1.insertChild(root_child1_child0, 0); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setFlexShrink(1); - root_child2.setFlexBasis("0%"); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(0); - expect(root_child1_child0.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(50); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(0); - expect(root_child1_child0.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root_child1.setDisplay(Display.None); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setFlexGrow(1); + root_child1_child0.setFlexShrink(1); + root_child1_child0.setFlexBasis("0%"); + root_child1_child0.setWidth(20); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setFlexShrink(1); + root_child2.setFlexBasis("0%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(0); + expect(root_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(0); + expect(root_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(100); }); test('display_none_with_position', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setPosition(Edge.Top, 10); - root_child1.setDisplay(Display.None); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setPosition(Edge.Top, 10); + root_child1.setDisplay(Display.None); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); }); test('display_none_with_position_absolute', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(100); - root_child0.setHeight(100); - root_child0.setDisplay(Display.None); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(100); + root_child0.setHeight(100); + root_child0.setDisplay(Display.None); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); }); test('display_contents', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setDisplay(Display.Contents); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0_child0.setFlexBasis("0%"); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setFlexGrow(1); - root_child0_child1.setFlexShrink(1); - root_child0_child1.setFlexBasis("0%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(50); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setFlexGrow(1); + root_child0_child1.setFlexShrink(1); + root_child0_child1.setFlexBasis("0%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); }); test('display_contents_fixed_size', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root_child0.setDisplay(Display.Contents); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0_child0.setFlexBasis("0%"); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setFlexGrow(1); - root_child0_child1.setFlexShrink(1); - root_child0_child1.setFlexBasis("0%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(50); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setFlexGrow(1); + root_child0_child1.setFlexShrink(1); + root_child0_child1.setFlexBasis("0%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); }); test('display_contents_with_margin', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 10); - root_child0.setMargin(Edge.Top, 10); - root_child0.setMargin(Edge.Right, 10); - root_child0.setMargin(Edge.Bottom, 10); - root_child0.setWidth(20); - root_child0.setHeight(20); - root_child0.setDisplay(Display.Contents); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 10); + root_child0.setMargin(Edge.Top, 10); + root_child0.setMargin(Edge.Right, 10); + root_child0.setMargin(Edge.Bottom, 10); + root_child0.setWidth(20); + root_child0.setHeight(20); + root_child0.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); }); test('display_contents_with_padding', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 10); - root_child0.setPadding(Edge.Top, 10); - root_child0.setPadding(Edge.Right, 10); - root_child0.setPadding(Edge.Bottom, 10); - root_child0.setDisplay(Display.Contents); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0_child0.setFlexBasis("0%"); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setFlexGrow(1); - root_child0_child1.setFlexShrink(1); - root_child0_child1.setFlexBasis("0%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(50); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 10); + root_child0.setPadding(Edge.Top, 10); + root_child0.setPadding(Edge.Right, 10); + root_child0.setPadding(Edge.Bottom, 10); + root_child0.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setFlexGrow(1); + root_child0_child1.setFlexShrink(1); + root_child0_child1.setFlexBasis("0%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); }); test('display_contents_with_position', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPosition(Edge.Top, 10); - root_child0.setDisplay(Display.Contents); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0_child0.setFlexBasis("0%"); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setFlexGrow(1); - root_child0_child1.setFlexShrink(1); - root_child0_child1.setFlexBasis("0%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(50); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPosition(Edge.Top, 10); + root_child0.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setFlexGrow(1); + root_child0_child1.setFlexShrink(1); + root_child0_child1.setFlexBasis("0%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); }); test('display_contents_with_position_absolute', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(50); - root_child0.setHeight(50); - root_child0.setDisplay(Display.Contents); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0_child0.setFlexBasis("0%"); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setFlexGrow(1); - root_child0_child1.setFlexShrink(1); - root_child0_child1.setFlexBasis("0%"); - root_child0_child1.setHeight(20); - root_child0.insertChild(root_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(50); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setFlexGrow(1); + root_child0_child1.setFlexShrink(1); + root_child0_child1.setFlexBasis("0%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); }); test('display_contents_nested', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setDisplay(Display.Contents); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setDisplay(Display.Contents); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setFlexGrow(1); - root_child0_child0_child0.setFlexShrink(1); - root_child0_child0_child0.setFlexBasis("0%"); - root_child0_child0_child0.setHeight(10); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child1 = Yoga.Node.create(config); - root_child0_child0_child1.setFlexGrow(1); - root_child0_child0_child1.setFlexShrink(1); - root_child0_child0_child1.setFlexBasis("0%"); - root_child0_child0_child1.setHeight(20); - root_child0_child0.insertChild(root_child0_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(50); - expect(root_child0_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child0_child1.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child0_child1.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setDisplay(Display.Contents); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setFlexGrow(1); + root_child0_child0_child0.setFlexShrink(1); + root_child0_child0_child0.setFlexBasis("0%"); + root_child0_child0_child0.setHeight(10); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setFlexGrow(1); + root_child0_child0_child1.setFlexShrink(1); + root_child0_child0_child1.setFlexBasis("0%"); + root_child0_child0_child1.setHeight(20); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child0_child1.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child0_child1.getComputedHeight()).toBe(20); }); test('display_contents_with_siblings', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis("0%"); - root_child0.setHeight(30); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setDisplay(Display.Contents); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setFlexGrow(1); - root_child1_child0.setFlexShrink(1); - root_child1_child0.setFlexBasis("0%"); - root_child1_child0.setHeight(10); - root_child1.insertChild(root_child1_child0, 0); - - const root_child1_child1 = Yoga.Node.create(config); - root_child1_child1.setFlexGrow(1); - root_child1_child1.setFlexShrink(1); - root_child1_child1.setFlexBasis("0%"); - root_child1_child1.setHeight(20); - root_child1.insertChild(root_child1_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setFlexShrink(1); - root_child2.setFlexBasis("0%"); - root_child2.setHeight(30); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(25); - expect(root_child0.getComputedHeight()).toBe(30); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child1_child0.getComputedLeft()).toBe(25); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(25); - expect(root_child1_child0.getComputedHeight()).toBe(10); - - expect(root_child1_child1.getComputedLeft()).toBe(50); - expect(root_child1_child1.getComputedTop()).toBe(0); - expect(root_child1_child1.getComputedWidth()).toBe(25); - expect(root_child1_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(75); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(30); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(25); - expect(root_child0.getComputedHeight()).toBe(30); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child1_child0.getComputedLeft()).toBe(50); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(25); - expect(root_child1_child0.getComputedHeight()).toBe(10); - - expect(root_child1_child1.getComputedLeft()).toBe(25); - expect(root_child1_child1.getComputedTop()).toBe(0); - expect(root_child1_child1.getComputedWidth()).toBe(25); - expect(root_child1_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(30); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root_child0.setHeight(30); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setDisplay(Display.Contents); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setFlexGrow(1); + root_child1_child0.setFlexShrink(1); + root_child1_child0.setFlexBasis("0%"); + root_child1_child0.setHeight(10); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setFlexGrow(1); + root_child1_child1.setFlexShrink(1); + root_child1_child1.setFlexBasis("0%"); + root_child1_child1.setHeight(20); + root_child1.insertChild(root_child1_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setFlexShrink(1); + root_child2.setFlexBasis("0%"); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child1_child0.getComputedLeft()).toBe(25); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child1_child1.getComputedLeft()).toBe(50); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(25); + expect(root_child1_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(75); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(30); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child1_child0.getComputedLeft()).toBe(50); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child1_child1.getComputedLeft()).toBe(25); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(25); + expect(root_child1_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(30); }); diff --git a/javascript/tests/generated/YGFlexBasisFitContentInMainAxisTest.test.ts b/javascript/tests/generated/YGFlexBasisFitContentInMainAxisTest.test.ts index 85c657fed5..6a6e8f11f4 100644 --- a/javascript/tests/generated/YGFlexBasisFitContentInMainAxisTest.test.ts +++ b/javascript/tests/generated/YGFlexBasisFitContentInMainAxisTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexBasisFitContentInMainAxisTest.html */ @@ -30,461 +30,398 @@ import { test('container_child_overflows_definite_parent_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(500); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(500); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(150); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(500); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(500); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(500); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(150); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(500); }); test('container_child_overflows_definite_parent_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(300); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(500); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(500); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(-200); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(500); - expect(root_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(500); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(500); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(-200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(500); + expect(root_child0_child0.getComputedHeight()).toBe(50); }); test('container_child_within_bounds_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(150); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(150); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(100); }); test('multiple_container_children_overflow_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setHeight(400); - root_child0.insertChild(root_child0_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setHeight(500); - root_child1.insertChild(root_child1_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(400); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(400); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(500); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(200); - expect(root_child1_child0.getComputedHeight()).toBe(500); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(400); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(400); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(500); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(200); - expect(root_child1_child0.getComputedHeight()).toBe(500); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setHeight(400); + root_child0.insertChild(root_child0_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setHeight(500); + root_child1.insertChild(root_child1_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(400); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(400); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(500); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(200); + expect(root_child1_child0.getComputedHeight()).toBe(500); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(400); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(400); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(500); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(200); + expect(root_child1_child0.getComputedHeight()).toBe(500); }); test('scroll_container_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setOverflow(Overflow.Scroll); - root.setWidth(200); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setHeight(500); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(500); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(500); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setOverflow(Overflow.Scroll); + root.setWidth(200); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setHeight(500); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(500); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(500); }); test('explicit_and_container_children_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setHeight(500); - root_child1.insertChild(root_child1_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(100); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(500); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(200); - expect(root_child1_child0.getComputedHeight()).toBe(500); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(100); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(500); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(200); - expect(root_child1_child0.getComputedHeight()).toBe(500); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setHeight(500); + root_child1.insertChild(root_child1_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(500); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(200); + expect(root_child1_child0.getComputedHeight()).toBe(500); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(500); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(200); + expect(root_child1_child0.getComputedHeight()).toBe(500); }); test('flex_basis_in_scroll_content_container', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setOverflow(Overflow.Scroll); - root.setWidth(200); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexBasis(200); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setFlexBasis(300); - root_child0.insertChild(root_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(200); - expect(root_child0_child1.getComputedWidth()).toBe(200); - expect(root_child0_child1.getComputedHeight()).toBe(300); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(200); - expect(root_child0_child1.getComputedWidth()).toBe(200); - expect(root_child0_child1.getComputedHeight()).toBe(300); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setOverflow(Overflow.Scroll); + root.setWidth(200); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexBasis(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setFlexBasis(300); + root_child0.insertChild(root_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(200); + expect(root_child0_child1.getComputedWidth()).toBe(200); + expect(root_child0_child1.getComputedHeight()).toBe(300); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(200); + expect(root_child0_child1.getComputedWidth()).toBe(200); + expect(root_child0_child1.getComputedHeight()).toBe(300); }); diff --git a/javascript/tests/generated/YGFlexDirectionTest.test.ts b/javascript/tests/generated/YGFlexDirectionTest.test.ts index 2999befc5e..c7563c9d6d 100644 --- a/javascript/tests/generated/YGFlexDirectionTest.test.ts +++ b/javascript/tests/generated/YGFlexDirectionTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<285a0c9dd4b646e7b1af77658fc41d99>> + * @generated SignedSource<<68d7b5da8d4d0ba32c20afccc005e701>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexDirectionTest.html */ @@ -30,4533 +30,4038 @@ import { test('flex_direction_column_no_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(30); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(30); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(10); }); test('flex_direction_row_no_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(30); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(10); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(30); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(10); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(30); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(30); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); }); test('flex_direction_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(10); }); test('flex_direction_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(10); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(80); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(70); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); }); test('flex_direction_column_reverse', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.ColumnReverse); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(90); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(80); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(70); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(90); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(80); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(70); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(90); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(70); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(90); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(70); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(10); }); test('flex_direction_row_reverse', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(80); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(70); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(10); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_margin_left', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setPositionType(PositionType.Absolute); - root.setMargin(Edge.Left, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(100); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(80); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(70); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(100); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(10); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Left, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(100); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(100); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_margin_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setPositionType(PositionType.Absolute); - root.setMargin(Edge.Start, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(100); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(80); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(70); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(10); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Start, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(100); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_margin_right', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setPositionType(PositionType.Absolute); - root.setMargin(Edge.Right, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(80); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(70); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(10); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Right, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_margin_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setPositionType(PositionType.Absolute); - root.setMargin(Edge.End, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(80); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(70); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(100); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(10); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.End, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(100); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); }); test('flex_direction_column_reverse_margin_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.ColumnReverse); - root.setPositionType(PositionType.Absolute); - root.setMargin(Edge.Top, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(100); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(100); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(100); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(90); - expect(root_child1.getComputedTop()).toBe(100); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(90); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Top, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(100); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(100); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); }); test('flex_direction_column_reverse_margin_bottom', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.ColumnReverse); - root.setPositionType(PositionType.Absolute); - root.setMargin(Edge.Bottom, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(100); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(90); - expect(root_child1.getComputedTop()).toBe(100); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(90); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Bottom, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); }); test('flex_direction_row_reverse_padding_left', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(80); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(70); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(110); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(120); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(110); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_padding_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Start, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(80); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(70); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(10); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Start, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_padding_right', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Right, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(-10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(-20); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(-30); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(10); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Right, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(-20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(-30); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_padding_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.End, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(-10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(-20); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(-30); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(110); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(120); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.End, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(-20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(-30); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(110); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); }); test('flex_direction_column_reverse_padding_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.ColumnReverse); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Top, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(100); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(90); - expect(root_child1.getComputedTop()).toBe(100); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(90); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Top, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); }); test('flex_direction_column_reverse_padding_bottom', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.ColumnReverse); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Bottom, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(90); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(90); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Bottom, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); }); test('flex_direction_row_reverse_border_left', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Left, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(80); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(70); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(110); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(120); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(110); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_border_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Start, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(80); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(70); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(10); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Start, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_border_right', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Right, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(-10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(-20); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(-30); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(10); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Right, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(-20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(-30); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_border_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.End, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(-10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(-20); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(-30); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(110); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(120); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.End, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(-20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(-30); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(110); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); }); test('flex_direction_column_reverse_border_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.ColumnReverse); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Top, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(100); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(90); - expect(root_child1.getComputedTop()).toBe(100); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(90); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Top, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); }); test('flex_direction_column_reverse_border_bottom', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.ColumnReverse); - root.setPositionType(PositionType.Absolute); - root.setBorder(Edge.Bottom, 100); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(90); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(90); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Bottom, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); }); test('flex_direction_row_reverse_pos_left', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setPosition(Edge.Left, 100); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child1.getComputedLeft()).toBe(80); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(70); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child1.getComputedLeft()).toBe(10); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPosition(Edge.Left, 100); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child1.getComputedLeft()).toBe(80); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(70); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child1.getComputedLeft()).toBe(10); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_pos_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setPosition(Edge.Start, 100); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child1.getComputedLeft()).toBe(80); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(70); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(-100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child1.getComputedLeft()).toBe(10); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPosition(Edge.Start, 100); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child1.getComputedLeft()).toBe(80); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(70); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(-100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child1.getComputedLeft()).toBe(10); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_pos_right', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setPosition(Edge.Right, 100); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(-100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child1.getComputedLeft()).toBe(80); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(70); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(-100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child1.getComputedLeft()).toBe(10); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPosition(Edge.Right, 100); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(-100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child1.getComputedLeft()).toBe(80); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(70); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(-100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child1.getComputedLeft()).toBe(10); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_pos_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setPosition(Edge.End, 100); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(-100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child1.getComputedLeft()).toBe(80); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(70); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child1.getComputedLeft()).toBe(10); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(20); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPosition(Edge.End, 100); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(-100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child1.getComputedLeft()).toBe(80); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(70); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child1.getComputedLeft()).toBe(10); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_column_reverse_pos_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0.setPosition(Edge.Top, 100); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(90); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setPosition(Edge.Top, 100); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); }); test('flex_direction_column_reverse_pos_bottom', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0.setPosition(Edge.Bottom, 100); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(-100); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(-100); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(90); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setPosition(Edge.Bottom, 100); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(-100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(-100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); }); test('flex_direction_row_reverse_inner_pos_left', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setPosition(Edge.Left, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(10); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(10); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.Left, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_inner_pos_right', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setPosition(Edge.Right, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(80); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(80); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.Right, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_col_reverse_inner_pos_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setPosition(Edge.Top, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(10); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(10); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(90); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.Top, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); }); test('flex_direction_col_reverse_inner_pos_bottom', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setPosition(Edge.Bottom, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(80); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(80); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(90); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.Bottom, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(80); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(80); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); }); test.skip('flex_direction_row_reverse_inner_pos_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setPosition(Edge.Start, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(10); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(80); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.Start, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test.skip('flex_direction_row_reverse_inner_pos_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setPosition(Edge.End, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(80); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(10); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.End, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_inner_margin_left', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setMargin(Edge.Left, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(10); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.Left, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_inner_margin_right', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setMargin(Edge.Right, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(80); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.Right, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_col_reverse_inner_margin_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setMargin(Edge.Top, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(90); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(90); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(90); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.Top, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); }); test('flex_direction_col_reverse_inner_margin_bottom', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setMargin(Edge.Bottom, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(80); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(80); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(90); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.Bottom, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(80); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(80); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); }); test('flex_direction_row_reverse_inner_marign_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setMargin(Edge.Start, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.Start, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_inner_margin_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setMargin(Edge.End, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(80); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(10); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.End, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_inner_border_left', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setBorder(Edge.Left, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Left, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_inner_border_right', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setBorder(Edge.Right, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Right, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_col_reverse_inner_border_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(90); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(90); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(90); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); }); test('flex_direction_col_reverse_inner_border_bottom', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setBorder(Edge.Bottom, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(90); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(90); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(90); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Bottom, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); }); test('flex_direction_row_reverse_inner_border_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setBorder(Edge.Left, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Left, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_inner_border_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setBorder(Edge.Right, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Right, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_inner_padding_left', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setPadding(Edge.Left, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.Left, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_inner_padding_right', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setPadding(Edge.Right, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.Right, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_col_reverse_inner_padding_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setPadding(Edge.Top, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(90); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(90); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(90); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.Top, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); }); test('flex_direction_col_reverse_inner_padding_bottom', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(90); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(90); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(100); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(0); - - expect(root_child0_child2.getComputedLeft()).toBe(90); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); }); test('flex_direction_row_reverse_inner_padding_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setPadding(Edge.Start, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.Start, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_row_reverse_inner_padding_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setPadding(Edge.End, 10); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(10); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(90); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(80); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(10); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(10); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(10); - expect(root_child0_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.End, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); }); test('flex_direction_alternating_with_percent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setPosition(Edge.Left, "10%"); - root_child0.setPosition(Edge.Top, "10%"); - root_child0.setWidth("50%"); - root_child0.setHeight("50%"); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(30); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(150); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(120); - expect(root_child0.getComputedTop()).toBe(30); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(150); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setPosition(Edge.Left, "10%"); + root_child0.setPosition(Edge.Top, "10%"); + root_child0.setWidth("50%"); + root_child0.setHeight("50%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(120); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); }); diff --git a/javascript/tests/generated/YGFlexTest.test.ts b/javascript/tests/generated/YGFlexTest.test.ts index 6eee8e8640..f08b36d8c3 100644 --- a/javascript/tests/generated/YGFlexTest.test.ts +++ b/javascript/tests/generated/YGFlexTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<60e19ea0b6b108cd6b0d4062c0b0316d>> + * @generated SignedSource<<23161e158cb809e8677b1ec32f2df67e>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexTest.html */ @@ -30,648 +30,558 @@ import { test('flex_basis_flex_grow_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(75); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(75); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(75); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(75); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(75); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(75); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(25); }); test('flex_shrink_flex_grow_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(500); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexShrink(1); - root_child0.setWidth(500); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexShrink(1); - root_child1.setWidth(500); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(250); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(250); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(250); - expect(root_child1.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(250); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(250); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(250); - expect(root_child1.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexShrink(1); + root_child0.setWidth(500); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexShrink(1); + root_child1.setWidth(500); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(250); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(250); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(250); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(250); + expect(root_child1.getComputedHeight()).toBe(100); }); test('flex_shrink_flex_grow_child_flex_shrink_other_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(500); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexShrink(1); - root_child0.setWidth(500); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexShrink(1); - root_child1.setWidth(500); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(250); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(250); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(250); - expect(root_child1.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(250); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(250); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(250); - expect(root_child1.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexShrink(1); + root_child0.setWidth(500); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setWidth(500); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(250); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(250); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(250); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(250); + expect(root_child1.getComputedHeight()).toBe(100); }); test('flex_basis_flex_grow_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(75); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(25); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(75); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(75); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(75); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(100); }); test('flex_basis_flex_shrink_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexBasis(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexBasis(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); }); test('flex_basis_flex_shrink_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexBasis(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexBasis(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(100); }); test('flex_shrink_to_zero', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setHeight(75); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexShrink(1); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(75); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(50); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(75); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(50); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(75); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexShrink(1); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(75); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(75); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); }); test('flex_basis_overrides_main_size', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis(50); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(60); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(60); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(80); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(60); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(60); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(80); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(20); }); test('flex_grow_shrink_at_most', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(0); }); test('flex_grow_less_than_factor_one', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(0.2); - root_child0.setFlexBasis(40); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(0.2); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(0.4); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(132); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(132); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(92); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(224); - expect(root_child2.getComputedWidth()).toBe(200); - expect(root_child2.getComputedHeight()).toBe(184); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(132); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(132); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(92); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(224); - expect(root_child2.getComputedWidth()).toBe(200); - expect(root_child2.getComputedHeight()).toBe(184); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(0.2); + root_child0.setFlexBasis(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(0.2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(0.4); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(132); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(132); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(92); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(224); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(184); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(132); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(132); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(92); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(224); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(184); }); diff --git a/javascript/tests/generated/YGFlexWrapTest.test.ts b/javascript/tests/generated/YGFlexWrapTest.test.ts index 28ee4cee2e..2e4f748a40 100644 --- a/javascript/tests/generated/YGFlexWrapTest.test.ts +++ b/javascript/tests/generated/YGFlexWrapTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<5c4e3faf7c401d359b341c41a3055313>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexWrapTest.html */ @@ -30,2042 +30,1826 @@ import { test('wrap_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(30); - root_child0.setHeight(30); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(30); - root_child1.setHeight(30); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(30); - root_child2.setHeight(30); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(30); - root_child3.setHeight(30); - root.insertChild(root_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(30); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(30); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(30); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(60); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(30); - expect(root_child3.getComputedTop()).toBe(0); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(30); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(30); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(30); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(30); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(30); - - expect(root_child2.getComputedLeft()).toBe(30); - expect(root_child2.getComputedTop()).toBe(60); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(0); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(30); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(30); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(30); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(30); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(60); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(30); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(30); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(30); + expect(root_child2.getComputedTop()).toBe(60); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(30); }); test('wrap_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(30); - root_child0.setHeight(30); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(30); - root_child1.setHeight(30); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(30); - root_child2.setHeight(30); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(30); - root_child3.setHeight(30); - root.insertChild(root_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(60); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(30); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(30); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(30); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(30); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(60); - - expect(root_child0.getComputedLeft()).toBe(70); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(30); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(30); - - expect(root_child2.getComputedLeft()).toBe(10); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(70); - expect(root_child3.getComputedTop()).toBe(30); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(30); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(30); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(30); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(30); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(30); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(30); }); test('wrap_row_align_items_flex_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(30); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(30); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(30); - root_child2.setHeight(30); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(30); - root_child3.setHeight(30); - root.insertChild(root_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(60); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(30); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(30); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(60); - - expect(root_child0.getComputedLeft()).toBe(70); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(10); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(70); - expect(root_child3.getComputedTop()).toBe(30); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(30); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(30); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(30); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(30); }); test('wrap_row_align_items_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(30); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(30); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(30); - root_child2.setHeight(30); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(30); - root_child3.setHeight(30); - root.insertChild(root_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(60); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(5); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(30); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(30); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(60); - - expect(root_child0.getComputedLeft()).toBe(70); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(5); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(10); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(70); - expect(root_child3.getComputedTop()).toBe(30); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(30); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(30); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(5); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(30); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(5); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(30); }); test('flex_wrap_children_with_min_main_overriding_flex_basis', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexBasis(50); - root_child0.setMinWidth(55); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexBasis(50); - root_child1.setMinWidth(55); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(55); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(55); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(45); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(55); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(45); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(55); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexBasis(50); + root_child0.setMinWidth(55); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexBasis(50); + root_child1.setMinWidth(55); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(55); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(55); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(55); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(45); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(55); + expect(root_child1.getComputedHeight()).toBe(50); }); test('flex_wrap_wrap_to_child_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setAlignItems(Align.FlexStart); - root_child0.setFlexWrap(Wrap.Wrap); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setWidth(100); - root_child0_child0_child0.setHeight(100); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(100); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(100); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(100); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setAlignItems(Align.FlexStart); + root_child0.setFlexWrap(Wrap.Wrap); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(100); + root_child0_child0_child0.setHeight(100); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); }); test('flex_wrap_align_stretch_fits_one_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(150); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(150); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(0); }); test('wrap_reverse_row_align_content_flex_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.WrapReverse); - root.setWidth(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(30); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(30); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(30); - root_child2.setHeight(30); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(30); - root_child3.setHeight(40); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(30); - root_child4.setHeight(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(80); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(70); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(60); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(50); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(10); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(40); - - expect(root_child4.getComputedLeft()).toBe(30); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(30); - expect(root_child4.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(80); - - expect(root_child0.getComputedLeft()).toBe(70); - expect(root_child0.getComputedTop()).toBe(70); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(60); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(10); - expect(root_child2.getComputedTop()).toBe(50); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(70); - expect(root_child3.getComputedTop()).toBe(10); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(40); - - expect(root_child4.getComputedLeft()).toBe(40); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(30); - expect(root_child4.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(40); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(30); + root_child4.setHeight(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); }); test('wrap_reverse_row_align_content_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.WrapReverse); - root.setWidth(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(30); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(30); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(30); - root_child2.setHeight(30); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(30); - root_child3.setHeight(40); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(30); - root_child4.setHeight(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(80); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(70); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(60); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(50); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(10); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(40); - - expect(root_child4.getComputedLeft()).toBe(30); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(30); - expect(root_child4.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(80); - - expect(root_child0.getComputedLeft()).toBe(70); - expect(root_child0.getComputedTop()).toBe(70); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(60); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(10); - expect(root_child2.getComputedTop()).toBe(50); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(70); - expect(root_child3.getComputedTop()).toBe(10); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(40); - - expect(root_child4.getComputedLeft()).toBe(40); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(30); - expect(root_child4.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(40); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(30); + root_child4.setHeight(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); }); test('wrap_reverse_row_single_line_different_size', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.WrapReverse); - root.setWidth(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(30); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(30); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(30); - root_child2.setHeight(30); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(30); - root_child3.setHeight(40); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(30); - root_child4.setHeight(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(40); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(30); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(90); - expect(root_child3.getComputedTop()).toBe(10); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(40); - - expect(root_child4.getComputedLeft()).toBe(120); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(30); - expect(root_child4.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(270); - expect(root_child0.getComputedTop()).toBe(40); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(240); - expect(root_child1.getComputedTop()).toBe(30); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(210); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(180); - expect(root_child3.getComputedTop()).toBe(10); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(40); - - expect(root_child4.getComputedLeft()).toBe(150); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(30); - expect(root_child4.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(40); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(30); + root_child4.setHeight(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(40); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(90); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(270); + expect(root_child0.getComputedTop()).toBe(40); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(240); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(210); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(180); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(150); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); }); test('wrap_reverse_row_align_content_stretch', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.WrapReverse); - root.setWidth(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(30); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(30); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(30); - root_child2.setHeight(30); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(30); - root_child3.setHeight(40); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(30); - root_child4.setHeight(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(80); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(70); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(60); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(50); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(10); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(40); - - expect(root_child4.getComputedLeft()).toBe(30); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(30); - expect(root_child4.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(80); - - expect(root_child0.getComputedLeft()).toBe(70); - expect(root_child0.getComputedTop()).toBe(70); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(60); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(10); - expect(root_child2.getComputedTop()).toBe(50); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(70); - expect(root_child3.getComputedTop()).toBe(10); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(40); - - expect(root_child4.getComputedLeft()).toBe(40); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(30); - expect(root_child4.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(40); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(30); + root_child4.setHeight(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); }); test('wrap_reverse_row_align_content_space_around', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceAround); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.WrapReverse); - root.setWidth(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(30); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(30); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(30); - root_child2.setHeight(30); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(30); - root_child3.setHeight(40); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(30); - root_child4.setHeight(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(80); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(70); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(60); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(50); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(10); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(40); - - expect(root_child4.getComputedLeft()).toBe(30); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(30); - expect(root_child4.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(80); - - expect(root_child0.getComputedLeft()).toBe(70); - expect(root_child0.getComputedTop()).toBe(70); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(60); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(10); - expect(root_child2.getComputedTop()).toBe(50); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(70); - expect(root_child3.getComputedTop()).toBe(10); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(40); - - expect(root_child4.getComputedLeft()).toBe(40); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(30); - expect(root_child4.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(40); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(30); + root_child4.setHeight(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); }); test('wrap_reverse_column_fixed_size', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.WrapReverse); - root.setWidth(200); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(30); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(30); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(30); - root_child2.setHeight(30); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(30); - root_child3.setHeight(40); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(30); - root_child4.setHeight(50); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(170); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(170); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(170); - expect(root_child2.getComputedTop()).toBe(30); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(170); - expect(root_child3.getComputedTop()).toBe(60); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(40); - - expect(root_child4.getComputedLeft()).toBe(140); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(30); - expect(root_child4.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(30); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(30); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(60); - expect(root_child3.getComputedWidth()).toBe(30); - expect(root_child3.getComputedHeight()).toBe(40); - - expect(root_child4.getComputedLeft()).toBe(30); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(30); - expect(root_child4.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(200); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(40); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(30); + root_child4.setHeight(50); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(170); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(170); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(170); + expect(root_child2.getComputedTop()).toBe(30); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(170); + expect(root_child3.getComputedTop()).toBe(60); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(140); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(30); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(60); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); }); test('wrapped_row_within_align_items_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setFlexWrap(Wrap.Wrap); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(150); - root_child0_child0.setHeight(80); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(80); - root_child0_child1.setHeight(80); - root_child0.insertChild(root_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(160); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(150); - expect(root_child0_child0.getComputedHeight()).toBe(80); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(80); - expect(root_child0_child1.getComputedWidth()).toBe(80); - expect(root_child0_child1.getComputedHeight()).toBe(80); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(160); - - expect(root_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(150); - expect(root_child0_child0.getComputedHeight()).toBe(80); - - expect(root_child0_child1.getComputedLeft()).toBe(120); - expect(root_child0_child1.getComputedTop()).toBe(80); - expect(root_child0_child1.getComputedWidth()).toBe(80); - expect(root_child0_child1.getComputedHeight()).toBe(80); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(150); + root_child0_child0.setHeight(80); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(80); + root_child0_child1.setHeight(80); + root_child0.insertChild(root_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(160); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(150); + expect(root_child0_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(80); + expect(root_child0_child1.getComputedWidth()).toBe(80); + expect(root_child0_child1.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(160); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(150); + expect(root_child0_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child1.getComputedLeft()).toBe(120); + expect(root_child0_child1.getComputedTop()).toBe(80); + expect(root_child0_child1.getComputedWidth()).toBe(80); + expect(root_child0_child1.getComputedHeight()).toBe(80); }); test('wrapped_row_within_align_items_flex_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setFlexWrap(Wrap.Wrap); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(150); - root_child0_child0.setHeight(80); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(80); - root_child0_child1.setHeight(80); - root_child0.insertChild(root_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(160); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(150); - expect(root_child0_child0.getComputedHeight()).toBe(80); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(80); - expect(root_child0_child1.getComputedWidth()).toBe(80); - expect(root_child0_child1.getComputedHeight()).toBe(80); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(160); - - expect(root_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(150); - expect(root_child0_child0.getComputedHeight()).toBe(80); - - expect(root_child0_child1.getComputedLeft()).toBe(120); - expect(root_child0_child1.getComputedTop()).toBe(80); - expect(root_child0_child1.getComputedWidth()).toBe(80); - expect(root_child0_child1.getComputedHeight()).toBe(80); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(150); + root_child0_child0.setHeight(80); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(80); + root_child0_child1.setHeight(80); + root_child0.insertChild(root_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(160); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(150); + expect(root_child0_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(80); + expect(root_child0_child1.getComputedWidth()).toBe(80); + expect(root_child0_child1.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(160); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(150); + expect(root_child0_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child1.getComputedLeft()).toBe(120); + expect(root_child0_child1.getComputedTop()).toBe(80); + expect(root_child0_child1.getComputedWidth()).toBe(80); + expect(root_child0_child1.getComputedHeight()).toBe(80); }); test('wrapped_row_within_align_items_flex_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setFlexWrap(Wrap.Wrap); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(150); - root_child0_child0.setHeight(80); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(80); - root_child0_child1.setHeight(80); - root_child0.insertChild(root_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(160); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(150); - expect(root_child0_child0.getComputedHeight()).toBe(80); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(80); - expect(root_child0_child1.getComputedWidth()).toBe(80); - expect(root_child0_child1.getComputedHeight()).toBe(80); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(160); - - expect(root_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(150); - expect(root_child0_child0.getComputedHeight()).toBe(80); - - expect(root_child0_child1.getComputedLeft()).toBe(120); - expect(root_child0_child1.getComputedTop()).toBe(80); - expect(root_child0_child1.getComputedWidth()).toBe(80); - expect(root_child0_child1.getComputedHeight()).toBe(80); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(150); + root_child0_child0.setHeight(80); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(80); + root_child0_child1.setHeight(80); + root_child0.insertChild(root_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(160); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(150); + expect(root_child0_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(80); + expect(root_child0_child1.getComputedWidth()).toBe(80); + expect(root_child0_child1.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(160); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(150); + expect(root_child0_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child1.getComputedLeft()).toBe(120); + expect(root_child0_child1.getComputedTop()).toBe(80); + expect(root_child0_child1.getComputedWidth()).toBe(80); + expect(root_child0_child1.getComputedHeight()).toBe(80); }); test('wrapped_column_max_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setAlignContent(Align.Center); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(700); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(100); - root_child0.setHeight(500); - root_child0.setMaxHeight(200); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setMargin(Edge.Left, 20); - root_child1.setMargin(Edge.Top, 20); - root_child1.setMargin(Edge.Right, 20); - root_child1.setMargin(Edge.Bottom, 20); - root_child1.setWidth(200); - root_child1.setHeight(200); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(100); - root_child2.setHeight(100); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(700); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(250); - expect(root_child0.getComputedTop()).toBe(30); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(200); - expect(root_child1.getComputedTop()).toBe(250); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(200); - - expect(root_child2.getComputedLeft()).toBe(420); - expect(root_child2.getComputedTop()).toBe(200); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(700); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(350); - expect(root_child0.getComputedTop()).toBe(30); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(300); - expect(root_child1.getComputedTop()).toBe(250); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(200); - - expect(root_child2.getComputedLeft()).toBe(180); - expect(root_child2.getComputedTop()).toBe(200); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignContent(Align.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(700); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(500); + root_child0.setMaxHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Left, 20); + root_child1.setMargin(Edge.Top, 20); + root_child1.setMargin(Edge.Right, 20); + root_child1.setMargin(Edge.Bottom, 20); + root_child1.setWidth(200); + root_child1.setHeight(200); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(700); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(250); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(250); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(200); + + expect(root_child2.getComputedLeft()).toBe(420); + expect(root_child2.getComputedTop()).toBe(200); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(700); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(350); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(300); + expect(root_child1.getComputedTop()).toBe(250); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(200); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(200); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); }); test('wrapped_column_max_height_flex', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setAlignContent(Align.Center); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(700); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis("0%"); - root_child0.setWidth(100); - root_child0.setHeight(500); - root_child0.setMaxHeight(200); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexShrink(1); - root_child1.setFlexBasis("0%"); - root_child1.setMargin(Edge.Left, 20); - root_child1.setMargin(Edge.Top, 20); - root_child1.setMargin(Edge.Right, 20); - root_child1.setMargin(Edge.Bottom, 20); - root_child1.setWidth(200); - root_child1.setHeight(200); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(100); - root_child2.setHeight(100); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(700); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(300); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(180); - - expect(root_child1.getComputedLeft()).toBe(250); - expect(root_child1.getComputedTop()).toBe(200); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(180); - - expect(root_child2.getComputedLeft()).toBe(300); - expect(root_child2.getComputedTop()).toBe(400); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(700); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(300); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(180); - - expect(root_child1.getComputedLeft()).toBe(250); - expect(root_child1.getComputedTop()).toBe(200); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(180); - - expect(root_child2.getComputedLeft()).toBe(300); - expect(root_child2.getComputedTop()).toBe(400); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignContent(Align.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(700); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root_child0.setWidth(100); + root_child0.setHeight(500); + root_child0.setMaxHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root_child1.setMargin(Edge.Left, 20); + root_child1.setMargin(Edge.Top, 20); + root_child1.setMargin(Edge.Right, 20); + root_child1.setMargin(Edge.Bottom, 20); + root_child1.setWidth(200); + root_child1.setHeight(200); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(700); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(300); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(180); + + expect(root_child1.getComputedLeft()).toBe(250); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(180); + + expect(root_child2.getComputedLeft()).toBe(300); + expect(root_child2.getComputedTop()).toBe(400); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(700); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(300); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(180); + + expect(root_child1.getComputedLeft()).toBe(250); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(180); + + expect(root_child2.getComputedLeft()).toBe(300); + expect(root_child2.getComputedTop()).toBe(400); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); }); test('wrap_nodes_with_content_sizing_overflowing_margin', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(500); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setWidth(85); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setWidth(40); - root_child0_child0_child0.setHeight(40); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setMargin(Edge.Right, 10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child1_child0 = Yoga.Node.create(config); - root_child0_child1_child0.setWidth(40); - root_child0_child1_child0.setHeight(40); - root_child0_child1.insertChild(root_child0_child1_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(85); - expect(root_child0.getComputedHeight()).toBe(80); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0.getComputedHeight()).toBe(40); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(40); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(40); - expect(root_child0_child1.getComputedWidth()).toBe(40); - expect(root_child0_child1.getComputedHeight()).toBe(40); - - expect(root_child0_child1_child0.getComputedLeft()).toBe(0); - expect(root_child0_child1_child0.getComputedTop()).toBe(0); - expect(root_child0_child1_child0.getComputedWidth()).toBe(40); - expect(root_child0_child1_child0.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(415); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(85); - expect(root_child0.getComputedHeight()).toBe(80); - - expect(root_child0_child0.getComputedLeft()).toBe(45); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0.getComputedHeight()).toBe(40); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(40); - - expect(root_child0_child1.getComputedLeft()).toBe(35); - expect(root_child0_child1.getComputedTop()).toBe(40); - expect(root_child0_child1.getComputedWidth()).toBe(40); - expect(root_child0_child1.getComputedHeight()).toBe(40); - - expect(root_child0_child1_child0.getComputedLeft()).toBe(0); - expect(root_child0_child1_child0.getComputedTop()).toBe(0); - expect(root_child0_child1_child0.getComputedWidth()).toBe(40); - expect(root_child0_child1_child0.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setWidth(85); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(40); + root_child0_child0_child0.setHeight(40); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setMargin(Edge.Right, 10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child1_child0.setWidth(40); + root_child0_child1_child0.setHeight(40); + root_child0_child1.insertChild(root_child0_child1_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(85); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(40); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child1_child0.getComputedLeft()).toBe(0); + expect(root_child0_child1_child0.getComputedTop()).toBe(0); + expect(root_child0_child1_child0.getComputedWidth()).toBe(40); + expect(root_child0_child1_child0.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(415); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(85); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child0.getComputedLeft()).toBe(45); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(35); + expect(root_child0_child1.getComputedTop()).toBe(40); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child1_child0.getComputedLeft()).toBe(0); + expect(root_child0_child1_child0.getComputedTop()).toBe(0); + expect(root_child0_child1_child0.getComputedWidth()).toBe(40); + expect(root_child0_child1_child0.getComputedHeight()).toBe(40); }); test('wrap_nodes_with_content_sizing_margin_cross', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(500); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setWidth(70); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setWidth(40); - root_child0_child0_child0.setHeight(40); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setMargin(Edge.Top, 10); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child1_child0 = Yoga.Node.create(config); - root_child0_child1_child0.setWidth(40); - root_child0_child1_child0.setHeight(40); - root_child0_child1.insertChild(root_child0_child1_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(70); - expect(root_child0.getComputedHeight()).toBe(90); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0.getComputedHeight()).toBe(40); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(40); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(40); - expect(root_child0_child1.getComputedHeight()).toBe(40); - - expect(root_child0_child1_child0.getComputedLeft()).toBe(0); - expect(root_child0_child1_child0.getComputedTop()).toBe(0); - expect(root_child0_child1_child0.getComputedWidth()).toBe(40); - expect(root_child0_child1_child0.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(430); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(70); - expect(root_child0.getComputedHeight()).toBe(90); - - expect(root_child0_child0.getComputedLeft()).toBe(30); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0.getComputedHeight()).toBe(40); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(40); - - expect(root_child0_child1.getComputedLeft()).toBe(30); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(40); - expect(root_child0_child1.getComputedHeight()).toBe(40); - - expect(root_child0_child1_child0.getComputedLeft()).toBe(0); - expect(root_child0_child1_child0.getComputedTop()).toBe(0); - expect(root_child0_child1_child0.getComputedWidth()).toBe(40); - expect(root_child0_child1_child0.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setWidth(70); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(40); + root_child0_child0_child0.setHeight(40); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setMargin(Edge.Top, 10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child1_child0.setWidth(40); + root_child0_child1_child0.setHeight(40); + root_child0_child1.insertChild(root_child0_child1_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(70); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child1_child0.getComputedLeft()).toBe(0); + expect(root_child0_child1_child0.getComputedTop()).toBe(0); + expect(root_child0_child1_child0.getComputedWidth()).toBe(40); + expect(root_child0_child1_child0.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(430); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(70); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child0_child0.getComputedLeft()).toBe(30); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(30); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child1_child0.getComputedLeft()).toBe(0); + expect(root_child0_child1_child0.getComputedTop()).toBe(0); + expect(root_child0_child1_child0.getComputedWidth()).toBe(40); + expect(root_child0_child1_child0.getComputedHeight()).toBe(40); }); test('wrap_with_min_cross_axis', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(500); - root.setMinHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(400); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(400); - root_child1.setHeight(200); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(200); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(100); - expect(root_child1.getComputedTop()).toBe(200); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(500); + root.setMinHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); }); test('wrap_with_max_cross_axis', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(500); - root.setMaxHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(400); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(400); - root_child1.setHeight(200); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(200); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(100); - expect(root_child1.getComputedTop()).toBe(200); - expect(root_child1.getComputedWidth()).toBe(400); - expect(root_child1.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(500); + root.setMaxHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); }); test('nowrap_expands_flexline_box_to_min_cross', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setMinHeight(400); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis("0%"); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(400); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(400); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setMinHeight(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(400); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(400); }); test('wrap_does_not_impose_min_cross_onto_single_flexline', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setMinHeight(400); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis("0%"); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setMinHeight(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); }); diff --git a/javascript/tests/generated/YGGapTest.test.ts b/javascript/tests/generated/YGGapTest.test.ts index d38f592eaa..0f89192e46 100644 --- a/javascript/tests/generated/YGGapTest.test.ts +++ b/javascript/tests/generated/YGGapTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<3fad56933a314f0a81b6ed504040ffae>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGGapTest.html */ @@ -30,3274 +30,2977 @@ import { test('column_gap_flexible', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(80); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - root.setGap(Gutter.Row, 20); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis("0%"); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexShrink(1); - root_child1.setFlexBasis("0%"); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setFlexShrink(1); - root_child2.setFlexBasis("0%"); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(80); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setFlexShrink(1); + root_child2.setFlexBasis("0%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); }); test('column_gap_inflexible', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(80); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(80); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); }); test('column_gap_mixed_flexible', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(80); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexShrink(1); - root_child1.setFlexBasis("0%"); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(80); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); }); test('column_gap_child_margins', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(80); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis("0%"); - root_child0.setMargin(Edge.Left, 2); - root_child0.setMargin(Edge.Right, 2); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexShrink(1); - root_child1.setFlexBasis("0%"); - root_child1.setMargin(Edge.Left, 10); - root_child1.setMargin(Edge.Right, 10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setFlexShrink(1); - root_child2.setFlexBasis("0%"); - root_child2.setMargin(Edge.Left, 15); - root_child2.setMargin(Edge.Right, 15); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(2); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(2); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(26); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(2); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(63); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(2); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(76); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(2); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(52); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(2); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(15); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(2); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(80); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root_child0.setMargin(Edge.Left, 2); + root_child0.setMargin(Edge.Right, 2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root_child1.setMargin(Edge.Left, 10); + root_child1.setMargin(Edge.Right, 10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setFlexShrink(1); + root_child2.setFlexBasis("0%"); + root_child2.setMargin(Edge.Left, 15); + root_child2.setMargin(Edge.Right, 15); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(2); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(26); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(2); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(63); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(2); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(76); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(52); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(2); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(15); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(2); + expect(root_child2.getComputedHeight()).toBe(100); }); test('column_row_gap_wrapping', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(80); - root.setGap(Gutter.Column, 10); - root.setGap(Gutter.Row, 20); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root_child2.setHeight(20); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(20); - root_child3.setHeight(20); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(20); - root_child4.setHeight(20); - root.insertChild(root_child4, 4); - - const root_child5 = Yoga.Node.create(config); - root_child5.setWidth(20); - root_child5.setHeight(20); - root.insertChild(root_child5, 5); - - const root_child6 = Yoga.Node.create(config); - root_child6.setWidth(20); - root_child6.setHeight(20); - root.insertChild(root_child6, 6); - - const root_child7 = Yoga.Node.create(config); - root_child7.setWidth(20); - root_child7.setHeight(20); - root.insertChild(root_child7, 7); - - const root_child8 = Yoga.Node.create(config); - root_child8.setWidth(20); - root_child8.setHeight(20); - root.insertChild(root_child8, 8); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(40); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(30); - expect(root_child4.getComputedTop()).toBe(40); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(20); - - expect(root_child5.getComputedLeft()).toBe(60); - expect(root_child5.getComputedTop()).toBe(40); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(20); - - expect(root_child6.getComputedLeft()).toBe(0); - expect(root_child6.getComputedTop()).toBe(80); - expect(root_child6.getComputedWidth()).toBe(20); - expect(root_child6.getComputedHeight()).toBe(20); - - expect(root_child7.getComputedLeft()).toBe(30); - expect(root_child7.getComputedTop()).toBe(80); - expect(root_child7.getComputedWidth()).toBe(20); - expect(root_child7.getComputedHeight()).toBe(20); - - expect(root_child8.getComputedLeft()).toBe(60); - expect(root_child8.getComputedTop()).toBe(80); - expect(root_child8.getComputedWidth()).toBe(20); - expect(root_child8.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child3.getComputedLeft()).toBe(60); - expect(root_child3.getComputedTop()).toBe(40); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(30); - expect(root_child4.getComputedTop()).toBe(40); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(20); - - expect(root_child5.getComputedLeft()).toBe(0); - expect(root_child5.getComputedTop()).toBe(40); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(20); - - expect(root_child6.getComputedLeft()).toBe(60); - expect(root_child6.getComputedTop()).toBe(80); - expect(root_child6.getComputedWidth()).toBe(20); - expect(root_child6.getComputedHeight()).toBe(20); - - expect(root_child7.getComputedLeft()).toBe(30); - expect(root_child7.getComputedTop()).toBe(80); - expect(root_child7.getComputedWidth()).toBe(20); - expect(root_child7.getComputedHeight()).toBe(20); - - expect(root_child8.getComputedLeft()).toBe(0); - expect(root_child8.getComputedTop()).toBe(80); - expect(root_child8.getComputedWidth()).toBe(20); - expect(root_child8.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(80); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(20); + root_child3.setHeight(20); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(20); + root_child4.setHeight(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth(20); + root_child5.setHeight(20); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root_child6.setWidth(20); + root_child6.setHeight(20); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root_child7.setWidth(20); + root_child7.setHeight(20); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root_child8.setWidth(20); + root_child8.setHeight(20); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child7.getComputedLeft()).toBe(30); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(20); + expect(root_child7.getComputedHeight()).toBe(20); + + expect(root_child8.getComputedLeft()).toBe(60); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(20); + expect(root_child8.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(60); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); + + expect(root_child6.getComputedLeft()).toBe(60); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child7.getComputedLeft()).toBe(30); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(20); + expect(root_child7.getComputedHeight()).toBe(20); + + expect(root_child8.getComputedLeft()).toBe(0); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(20); + expect(root_child8.getComputedHeight()).toBe(20); }); test('column_gap_start_index', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(80); - root.setGap(Gutter.Column, 10); - root.setGap(Gutter.Row, 20); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root_child2.setHeight(20); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(20); - root_child3.setHeight(20); - root.insertChild(root_child3, 3); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(20); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(30); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child3.getComputedLeft()).toBe(60); - expect(root_child3.getComputedTop()).toBe(0); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(20); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(60); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(30); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(0); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(80); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(20); + root_child3.setHeight(20); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(30); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(60); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(30); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); }); test('column_gap_justify_flex_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); }); test('column_gap_justify_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(70); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(70); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(10); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); }); test('column_gap_justify_flex_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(80); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); }); test('column_gap_justify_space_between', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.SpaceBetween); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(80); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); }); test('column_gap_justify_space_around', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.SpaceAround); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(3); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(77); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(77); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(3); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(3); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(77); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(77); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(3); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); }); test('column_gap_justify_space_evenly', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.SpaceEvenly); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(5); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(75); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(5); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(75); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(5); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); }); test('column_gap_wrap_align_flex_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - root.setGap(Gutter.Row, 20); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root_child2.setHeight(20); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(20); - root_child3.setHeight(20); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(20); - root_child4.setHeight(20); - root.insertChild(root_child4, 4); - - const root_child5 = Yoga.Node.create(config); - root_child5.setWidth(20); - root_child5.setHeight(20); - root.insertChild(root_child5, 5); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(40); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(30); - expect(root_child4.getComputedTop()).toBe(40); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(20); - - expect(root_child5.getComputedLeft()).toBe(60); - expect(root_child5.getComputedTop()).toBe(40); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child3.getComputedLeft()).toBe(80); - expect(root_child3.getComputedTop()).toBe(40); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(40); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(20); - - expect(root_child5.getComputedLeft()).toBe(20); - expect(root_child5.getComputedTop()).toBe(40); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(20); + root_child3.setHeight(20); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(20); + root_child4.setHeight(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth(20); + root_child5.setHeight(20); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); }); test('column_gap_wrap_align_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - root.setGap(Gutter.Row, 20); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root_child2.setHeight(20); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(20); - root_child3.setHeight(20); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(20); - root_child4.setHeight(20); - root.insertChild(root_child4, 4); - - const root_child5 = Yoga.Node.create(config); - root_child5.setWidth(20); - root_child5.setHeight(20); - root.insertChild(root_child5, 5); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(20); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(60); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(30); - expect(root_child4.getComputedTop()).toBe(60); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(20); - - expect(root_child5.getComputedLeft()).toBe(60); - expect(root_child5.getComputedTop()).toBe(60); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(20); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child3.getComputedLeft()).toBe(80); - expect(root_child3.getComputedTop()).toBe(60); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(60); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(20); - - expect(root_child5.getComputedLeft()).toBe(20); - expect(root_child5.getComputedTop()).toBe(60); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(20); + root_child3.setHeight(20); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(20); + root_child4.setHeight(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth(20); + root_child5.setHeight(20); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(60); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(60); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(60); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(60); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(60); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(60); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); }); test('column_gap_wrap_align_flex_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - root.setGap(Gutter.Row, 20); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root_child2.setHeight(20); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(20); - root_child3.setHeight(20); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(20); - root_child4.setHeight(20); - root.insertChild(root_child4, 4); - - const root_child5 = Yoga.Node.create(config); - root_child5.setWidth(20); - root_child5.setHeight(20); - root.insertChild(root_child5, 5); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(40); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(40); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(80); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(30); - expect(root_child4.getComputedTop()).toBe(80); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(20); - - expect(root_child5.getComputedLeft()).toBe(60); - expect(root_child5.getComputedTop()).toBe(80); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(40); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(40); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(40); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child3.getComputedLeft()).toBe(80); - expect(root_child3.getComputedTop()).toBe(80); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(80); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(20); - - expect(root_child5.getComputedLeft()).toBe(20); - expect(root_child5.getComputedTop()).toBe(80); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(20); + root_child3.setHeight(20); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(20); + root_child4.setHeight(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth(20); + root_child5.setHeight(20); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(40); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(40); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); }); test('column_gap_wrap_align_space_between', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceBetween); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - root.setGap(Gutter.Row, 20); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root_child2.setHeight(20); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(20); - root_child3.setHeight(20); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(20); - root_child4.setHeight(20); - root.insertChild(root_child4, 4); - - const root_child5 = Yoga.Node.create(config); - root_child5.setWidth(20); - root_child5.setHeight(20); - root.insertChild(root_child5, 5); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(80); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(30); - expect(root_child4.getComputedTop()).toBe(80); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(20); - - expect(root_child5.getComputedLeft()).toBe(60); - expect(root_child5.getComputedTop()).toBe(80); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child3.getComputedLeft()).toBe(80); - expect(root_child3.getComputedTop()).toBe(80); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(80); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(20); - - expect(root_child5.getComputedLeft()).toBe(20); - expect(root_child5.getComputedTop()).toBe(80); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(20); + root_child3.setHeight(20); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(20); + root_child4.setHeight(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth(20); + root_child5.setHeight(20); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); }); test('column_gap_wrap_align_space_around', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.SpaceAround); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - root.setGap(Gutter.Row, 20); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root_child2.setHeight(20); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(20); - root_child3.setHeight(20); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(20); - root_child4.setHeight(20); - root.insertChild(root_child4, 4); - - const root_child5 = Yoga.Node.create(config); - root_child5.setWidth(20); - root_child5.setHeight(20); - root.insertChild(root_child5, 5); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(10); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(70); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(30); - expect(root_child4.getComputedTop()).toBe(70); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(20); - - expect(root_child5.getComputedLeft()).toBe(60); - expect(root_child5.getComputedTop()).toBe(70); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(10); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(20); - - expect(root_child3.getComputedLeft()).toBe(80); - expect(root_child3.getComputedTop()).toBe(70); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(20); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(70); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(20); - - expect(root_child5.getComputedLeft()).toBe(20); - expect(root_child5.getComputedTop()).toBe(70); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(20); + root_child3.setHeight(20); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(20); + root_child4.setHeight(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth(20); + root_child5.setHeight(20); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(70); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(70); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(70); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(70); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(70); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(70); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); }); test('column_gap_wrap_align_stretch', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(300); - root.setHeight(300); - root.setGap(Gutter.Column, 5); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setMinWidth(60); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setMinWidth(60); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setMinWidth(60); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setFlexGrow(1); - root_child3.setMinWidth(60); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setFlexGrow(1); - root_child4.setMinWidth(60); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(71); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child1.getComputedLeft()).toBe(76); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(72); - expect(root_child1.getComputedHeight()).toBe(150); - - expect(root_child2.getComputedLeft()).toBe(153); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(71); - expect(root_child2.getComputedHeight()).toBe(150); - - expect(root_child3.getComputedLeft()).toBe(229); - expect(root_child3.getComputedTop()).toBe(0); - expect(root_child3.getComputedWidth()).toBe(71); - expect(root_child3.getComputedHeight()).toBe(150); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(150); - expect(root_child4.getComputedWidth()).toBe(300); - expect(root_child4.getComputedHeight()).toBe(150); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(229); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(71); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child1.getComputedLeft()).toBe(153); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(71); - expect(root_child1.getComputedHeight()).toBe(150); - - expect(root_child2.getComputedLeft()).toBe(76); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(72); - expect(root_child2.getComputedHeight()).toBe(150); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(0); - expect(root_child3.getComputedWidth()).toBe(71); - expect(root_child3.getComputedHeight()).toBe(150); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(150); - expect(root_child4.getComputedWidth()).toBe(300); - expect(root_child4.getComputedHeight()).toBe(150); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + root.setGap(Gutter.Column, 5); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMinWidth(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setMinWidth(60); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setMinWidth(60); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setFlexGrow(1); + root_child3.setMinWidth(60); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setFlexGrow(1); + root_child4.setMinWidth(60); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(71); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(76); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(72); + expect(root_child1.getComputedHeight()).toBe(150); + + expect(root_child2.getComputedLeft()).toBe(153); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(71); + expect(root_child2.getComputedHeight()).toBe(150); + + expect(root_child3.getComputedLeft()).toBe(229); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(71); + expect(root_child3.getComputedHeight()).toBe(150); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(150); + expect(root_child4.getComputedWidth()).toBe(300); + expect(root_child4.getComputedHeight()).toBe(150); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(229); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(71); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(153); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(71); + expect(root_child1.getComputedHeight()).toBe(150); + + expect(root_child2.getComputedLeft()).toBe(76); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(72); + expect(root_child2.getComputedHeight()).toBe(150); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(71); + expect(root_child3.getComputedHeight()).toBe(150); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(150); + expect(root_child4.getComputedWidth()).toBe(300); + expect(root_child4.getComputedHeight()).toBe(150); }); test('column_gap_determines_parent_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setHeight(100); - root.setGap(Gutter.Column, 10); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(30); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(20); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(50); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(70); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(100); }); test('row_gap_align_items_stretch', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(200); - root.setGap(Gutter.Column, 10); - root.setGap(Gutter.Row, 20); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(20); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(20); - root.insertChild(root_child4, 4); - - const root_child5 = Yoga.Node.create(config); - root_child5.setWidth(20); - root.insertChild(root_child5, 5); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(90); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(90); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(90); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(110); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(90); - - expect(root_child4.getComputedLeft()).toBe(30); - expect(root_child4.getComputedTop()).toBe(110); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(90); - - expect(root_child5.getComputedLeft()).toBe(60); - expect(root_child5.getComputedTop()).toBe(110); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(90); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(90); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(90); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(90); - - expect(root_child3.getComputedLeft()).toBe(80); - expect(root_child3.getComputedTop()).toBe(110); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(90); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(110); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(90); - - expect(root_child5.getComputedLeft()).toBe(20); - expect(root_child5.getComputedTop()).toBe(110); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(90); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(200); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(20); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth(20); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(90); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(110); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(90); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(110); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(90); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(110); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(90); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(90); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(110); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(90); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(110); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(90); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(110); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(90); }); test('row_gap_align_items_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(200); - root.setGap(Gutter.Column, 10); - root.setGap(Gutter.Row, 20); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(20); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(20); - root.insertChild(root_child4, 4); - - const root_child5 = Yoga.Node.create(config); - root_child5.setWidth(20); - root.insertChild(root_child5, 5); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(0); - - expect(root_child3.getComputedLeft()).toBe(0); - expect(root_child3.getComputedTop()).toBe(20); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(0); - - expect(root_child4.getComputedLeft()).toBe(30); - expect(root_child4.getComputedTop()).toBe(20); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(0); - - expect(root_child5.getComputedLeft()).toBe(60); - expect(root_child5.getComputedTop()).toBe(20); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(0); - - expect(root_child3.getComputedLeft()).toBe(80); - expect(root_child3.getComputedTop()).toBe(20); - expect(root_child3.getComputedWidth()).toBe(20); - expect(root_child3.getComputedHeight()).toBe(0); - - expect(root_child4.getComputedLeft()).toBe(50); - expect(root_child4.getComputedTop()).toBe(20); - expect(root_child4.getComputedWidth()).toBe(20); - expect(root_child4.getComputedHeight()).toBe(0); - - expect(root_child5.getComputedLeft()).toBe(20); - expect(root_child5.getComputedTop()).toBe(20); - expect(root_child5.getComputedWidth()).toBe(20); - expect(root_child5.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(200); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(20); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth(20); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(20); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(20); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(0); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(20); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(20); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(20); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(0); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(20); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(0); }); test('row_gap_column_child_margins', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(200); - root.setGap(Gutter.Row, 10); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis("0%"); - root_child0.setMargin(Edge.Top, 2); - root_child0.setMargin(Edge.Bottom, 2); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexShrink(1); - root_child1.setFlexBasis("0%"); - root_child1.setMargin(Edge.Top, 10); - root_child1.setMargin(Edge.Bottom, 10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setFlexShrink(1); - root_child2.setFlexBasis("0%"); - root_child2.setMargin(Edge.Top, 15); - root_child2.setMargin(Edge.Bottom, 15); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(2); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(42); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(66); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(42); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(143); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(42); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(2); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(42); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(66); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(42); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(143); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(42); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(200); + root.setGap(Gutter.Row, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root_child0.setMargin(Edge.Top, 2); + root_child0.setMargin(Edge.Bottom, 2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root_child1.setMargin(Edge.Top, 10); + root_child1.setMargin(Edge.Bottom, 10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setFlexShrink(1); + root_child2.setFlexBasis("0%"); + root_child2.setMargin(Edge.Top, 15); + root_child2.setMargin(Edge.Bottom, 15); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(2); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(42); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(66); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(42); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(143); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(42); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(2); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(42); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(66); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(42); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(143); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(42); }); test('row_gap_row_wrap_child_margins', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setHeight(200); - root.setGap(Gutter.Row, 10); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Top, 2); - root_child0.setMargin(Edge.Bottom, 2); - root_child0.setWidth(60); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setMargin(Edge.Top, 10); - root_child1.setMargin(Edge.Bottom, 10); - root_child1.setWidth(60); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setMargin(Edge.Top, 15); - root_child2.setMargin(Edge.Bottom, 15); - root_child2.setWidth(60); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(2); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(24); - expect(root_child1.getComputedWidth()).toBe(60); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(59); - expect(root_child2.getComputedWidth()).toBe(60); - expect(root_child2.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(40); - expect(root_child0.getComputedTop()).toBe(2); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(24); - expect(root_child1.getComputedWidth()).toBe(60); - expect(root_child1.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(40); - expect(root_child2.getComputedTop()).toBe(59); - expect(root_child2.getComputedWidth()).toBe(60); - expect(root_child2.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(200); + root.setGap(Gutter.Row, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 2); + root_child0.setMargin(Edge.Bottom, 2); + root_child0.setWidth(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Top, 10); + root_child1.setMargin(Edge.Bottom, 10); + root_child1.setWidth(60); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setMargin(Edge.Top, 15); + root_child2.setMargin(Edge.Bottom, 15); + root_child2.setWidth(60); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(2); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(24); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(59); + expect(root_child2.getComputedWidth()).toBe(60); + expect(root_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(2); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(24); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(59); + expect(root_child2.getComputedWidth()).toBe(60); + expect(root_child2.getComputedHeight()).toBe(0); }); test('row_gap_determines_parent_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setGap(Gutter.Row, 10); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setHeight(30); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(80); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(20); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(50); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(30); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(80); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(20); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(50); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(30); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setGap(Gutter.Row, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(30); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(30); }); test('row_gap_percent_wrapping', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setPadding(Edge.Left, 10); - root.setPadding(Edge.Top, 10); - root.setPadding(Edge.Right, 10); - root.setPadding(Edge.Bottom, 10); - root.setWidth(300); - root.setHeight(700); - root.setGap(Gutter.Column, "10%"); - root.setGap(Gutter.Row, "10%"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(100); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(100); - root_child2.setHeight(100); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(100); - root_child3.setHeight(100); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(100); - root_child4.setHeight(100); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(700); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(138); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(10); - expect(root_child2.getComputedTop()).toBe(178); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(138); - expect(root_child3.getComputedTop()).toBe(178); - expect(root_child3.getComputedWidth()).toBe(100); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(10); - expect(root_child4.getComputedTop()).toBe(346); - expect(root_child4.getComputedWidth()).toBe(100); - expect(root_child4.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(700); - - expect(root_child0.getComputedLeft()).toBe(190); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(62); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(190); - expect(root_child2.getComputedTop()).toBe(178); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(62); - expect(root_child3.getComputedTop()).toBe(178); - expect(root_child3.getComputedWidth()).toBe(100); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(190); - expect(root_child4.getComputedTop()).toBe(346); - expect(root_child4.getComputedWidth()).toBe(100); - expect(root_child4.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setPadding(Edge.Left, 10); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 10); + root.setPadding(Edge.Bottom, 10); + root.setWidth(300); + root.setHeight(700); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(100); + root_child3.setHeight(100); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(100); + root_child4.setHeight(100); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(138); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(138); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(10); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(190); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(62); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(190); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(62); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(190); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); }); test('row_gap_percent_determines_parent_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(300); - root.setGap(Gutter.Column, "10%"); - root.setGap(Gutter.Row, "10%"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(100); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(100); - root_child2.setHeight(100); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(100); - root_child3.setHeight(100); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(100); - root_child4.setHeight(100); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(130); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(130); - expect(root_child3.getComputedTop()).toBe(100); - expect(root_child3.getComputedWidth()).toBe(100); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(200); - expect(root_child4.getComputedWidth()).toBe(100); - expect(root_child4.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(200); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(70); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(200); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(70); - expect(root_child3.getComputedTop()).toBe(100); - expect(root_child3.getComputedWidth()).toBe(100); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(200); - expect(root_child4.getComputedTop()).toBe(200); - expect(root_child4.getComputedWidth()).toBe(100); - expect(root_child4.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(100); + root_child3.setHeight(100); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(100); + root_child4.setHeight(100); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(130); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(130); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(200); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(70); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(200); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(200); + expect(root_child4.getComputedTop()).toBe(200); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); }); test('row_gap_percent_wrapping_with_both_content_padding_and_item_padding', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setPadding(Edge.Left, 10); - root.setPadding(Edge.Top, 10); - root.setPadding(Edge.Right, 10); - root.setPadding(Edge.Bottom, 10); - root.setWidth(300); - root.setHeight(700); - root.setGap(Gutter.Column, "10%"); - root.setGap(Gutter.Row, "10%"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 10); - root_child0.setPadding(Edge.Top, 10); - root_child0.setPadding(Edge.Right, 10); - root_child0.setPadding(Edge.Bottom, 10); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setPadding(Edge.Left, 10); - root_child1.setPadding(Edge.Top, 10); - root_child1.setPadding(Edge.Right, 10); - root_child1.setPadding(Edge.Bottom, 10); - root_child1.setWidth(100); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setPadding(Edge.Left, 10); - root_child2.setPadding(Edge.Top, 10); - root_child2.setPadding(Edge.Right, 10); - root_child2.setPadding(Edge.Bottom, 10); - root_child2.setWidth(100); - root_child2.setHeight(100); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setPadding(Edge.Left, 10); - root_child3.setPadding(Edge.Top, 10); - root_child3.setPadding(Edge.Right, 10); - root_child3.setPadding(Edge.Bottom, 10); - root_child3.setWidth(100); - root_child3.setHeight(100); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setPadding(Edge.Left, 10); - root_child4.setPadding(Edge.Top, 10); - root_child4.setPadding(Edge.Right, 10); - root_child4.setPadding(Edge.Bottom, 10); - root_child4.setWidth(100); - root_child4.setHeight(100); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(700); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(138); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(10); - expect(root_child2.getComputedTop()).toBe(178); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(138); - expect(root_child3.getComputedTop()).toBe(178); - expect(root_child3.getComputedWidth()).toBe(100); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(10); - expect(root_child4.getComputedTop()).toBe(346); - expect(root_child4.getComputedWidth()).toBe(100); - expect(root_child4.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(700); - - expect(root_child0.getComputedLeft()).toBe(190); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(62); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(190); - expect(root_child2.getComputedTop()).toBe(178); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(62); - expect(root_child3.getComputedTop()).toBe(178); - expect(root_child3.getComputedWidth()).toBe(100); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(190); - expect(root_child4.getComputedTop()).toBe(346); - expect(root_child4.getComputedWidth()).toBe(100); - expect(root_child4.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setPadding(Edge.Left, 10); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 10); + root.setPadding(Edge.Bottom, 10); + root.setWidth(300); + root.setHeight(700); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 10); + root_child0.setPadding(Edge.Top, 10); + root_child0.setPadding(Edge.Right, 10); + root_child0.setPadding(Edge.Bottom, 10); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPadding(Edge.Left, 10); + root_child1.setPadding(Edge.Top, 10); + root_child1.setPadding(Edge.Right, 10); + root_child1.setPadding(Edge.Bottom, 10); + root_child1.setWidth(100); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setPadding(Edge.Left, 10); + root_child2.setPadding(Edge.Top, 10); + root_child2.setPadding(Edge.Right, 10); + root_child2.setPadding(Edge.Bottom, 10); + root_child2.setWidth(100); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setPadding(Edge.Left, 10); + root_child3.setPadding(Edge.Top, 10); + root_child3.setPadding(Edge.Right, 10); + root_child3.setPadding(Edge.Bottom, 10); + root_child3.setWidth(100); + root_child3.setHeight(100); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setPadding(Edge.Left, 10); + root_child4.setPadding(Edge.Top, 10); + root_child4.setPadding(Edge.Right, 10); + root_child4.setPadding(Edge.Bottom, 10); + root_child4.setWidth(100); + root_child4.setHeight(100); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(138); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(138); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(10); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(190); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(62); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(190); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(62); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(190); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); }); test('row_gap_percent_wrapping_with_both_content_padding', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setPadding(Edge.Left, 10); - root.setPadding(Edge.Top, 10); - root.setPadding(Edge.Right, 10); - root.setPadding(Edge.Bottom, 10); - root.setWidth(300); - root.setHeight(700); - root.setGap(Gutter.Column, "10%"); - root.setGap(Gutter.Row, "10%"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(100); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(100); - root_child2.setHeight(100); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(100); - root_child3.setHeight(100); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(100); - root_child4.setHeight(100); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(700); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(138); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(10); - expect(root_child2.getComputedTop()).toBe(178); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(138); - expect(root_child3.getComputedTop()).toBe(178); - expect(root_child3.getComputedWidth()).toBe(100); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(10); - expect(root_child4.getComputedTop()).toBe(346); - expect(root_child4.getComputedWidth()).toBe(100); - expect(root_child4.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(700); - - expect(root_child0.getComputedLeft()).toBe(190); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(62); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(190); - expect(root_child2.getComputedTop()).toBe(178); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(62); - expect(root_child3.getComputedTop()).toBe(178); - expect(root_child3.getComputedWidth()).toBe(100); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(190); - expect(root_child4.getComputedTop()).toBe(346); - expect(root_child4.getComputedWidth()).toBe(100); - expect(root_child4.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setPadding(Edge.Left, 10); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 10); + root.setPadding(Edge.Bottom, 10); + root.setWidth(300); + root.setHeight(700); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(100); + root_child3.setHeight(100); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(100); + root_child4.setHeight(100); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(138); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(138); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(10); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(190); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(62); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(190); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(62); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(190); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); }); test('row_gap_percent_wrapping_with_content_margin', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setMargin(Edge.Left, 10); - root.setMargin(Edge.Top, 10); - root.setMargin(Edge.Right, 10); - root.setMargin(Edge.Bottom, 10); - root.setWidth(300); - root.setHeight(700); - root.setGap(Gutter.Column, "10%"); - root.setGap(Gutter.Row, "10%"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(100); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(100); - root_child2.setHeight(100); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(100); - root_child3.setHeight(100); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(100); - root_child4.setHeight(100); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(10); - expect(root.getComputedTop()).toBe(10); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(700); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(130); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(170); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(130); - expect(root_child3.getComputedTop()).toBe(170); - expect(root_child3.getComputedWidth()).toBe(100); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(340); - expect(root_child4.getComputedWidth()).toBe(100); - expect(root_child4.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(10); - expect(root.getComputedTop()).toBe(10); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(700); - - expect(root_child0.getComputedLeft()).toBe(200); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(70); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(200); - expect(root_child2.getComputedTop()).toBe(170); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(70); - expect(root_child3.getComputedTop()).toBe(170); - expect(root_child3.getComputedWidth()).toBe(100); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(200); - expect(root_child4.getComputedTop()).toBe(340); - expect(root_child4.getComputedWidth()).toBe(100); - expect(root_child4.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setMargin(Edge.Left, 10); + root.setMargin(Edge.Top, 10); + root.setMargin(Edge.Right, 10); + root.setMargin(Edge.Bottom, 10); + root.setWidth(300); + root.setHeight(700); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(100); + root_child3.setHeight(100); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(100); + root_child4.setHeight(100); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(10); + expect(root.getComputedTop()).toBe(10); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(130); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(170); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(130); + expect(root_child3.getComputedTop()).toBe(170); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(340); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(10); + expect(root.getComputedTop()).toBe(10); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(70); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(200); + expect(root_child2.getComputedTop()).toBe(170); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(170); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(200); + expect(root_child4.getComputedTop()).toBe(340); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); }); test('row_gap_percent_wrapping_with_content_margin_and_padding', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setMargin(Edge.Left, 10); - root.setMargin(Edge.Top, 10); - root.setMargin(Edge.Right, 10); - root.setMargin(Edge.Bottom, 10); - root.setPadding(Edge.Left, 10); - root.setPadding(Edge.Top, 10); - root.setPadding(Edge.Right, 10); - root.setPadding(Edge.Bottom, 10); - root.setWidth(300); - root.setHeight(700); - root.setGap(Gutter.Column, "10%"); - root.setGap(Gutter.Row, "10%"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(100); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(100); - root_child2.setHeight(100); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(100); - root_child3.setHeight(100); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(100); - root_child4.setHeight(100); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(10); - expect(root.getComputedTop()).toBe(10); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(700); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(138); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(10); - expect(root_child2.getComputedTop()).toBe(178); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(138); - expect(root_child3.getComputedTop()).toBe(178); - expect(root_child3.getComputedWidth()).toBe(100); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(10); - expect(root_child4.getComputedTop()).toBe(346); - expect(root_child4.getComputedWidth()).toBe(100); - expect(root_child4.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(10); - expect(root.getComputedTop()).toBe(10); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(700); - - expect(root_child0.getComputedLeft()).toBe(190); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(62); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(190); - expect(root_child2.getComputedTop()).toBe(178); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(62); - expect(root_child3.getComputedTop()).toBe(178); - expect(root_child3.getComputedWidth()).toBe(100); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(190); - expect(root_child4.getComputedTop()).toBe(346); - expect(root_child4.getComputedWidth()).toBe(100); - expect(root_child4.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setMargin(Edge.Left, 10); + root.setMargin(Edge.Top, 10); + root.setMargin(Edge.Right, 10); + root.setMargin(Edge.Bottom, 10); + root.setPadding(Edge.Left, 10); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 10); + root.setPadding(Edge.Bottom, 10); + root.setWidth(300); + root.setHeight(700); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(100); + root_child3.setHeight(100); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(100); + root_child4.setHeight(100); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(10); + expect(root.getComputedTop()).toBe(10); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(138); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(138); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(10); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(10); + expect(root.getComputedTop()).toBe(10); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(190); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(62); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(190); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(62); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(190); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); }); test('row_gap_percent_wrapping_with_flexible_content', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(300); - root.setHeight(300); - root.setGap(Gutter.Column, "10%"); - root.setGap(Gutter.Row, "10%"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis("0%"); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexShrink(1); - root_child1.setFlexBasis("0%"); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setFlexShrink(1); - root_child2.setFlexBasis("0%"); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(80); - expect(root_child0.getComputedHeight()).toBe(300); - - expect(root_child1.getComputedLeft()).toBe(110); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(80); - expect(root_child1.getComputedHeight()).toBe(300); - - expect(root_child2.getComputedLeft()).toBe(220); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(80); - expect(root_child2.getComputedHeight()).toBe(300); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(220); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(80); - expect(root_child0.getComputedHeight()).toBe(300); - - expect(root_child1.getComputedLeft()).toBe(110); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(80); - expect(root_child1.getComputedHeight()).toBe(300); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(80); - expect(root_child2.getComputedHeight()).toBe(300); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setHeight(300); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setFlexShrink(1); + root_child2.setFlexBasis("0%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(300); + + expect(root_child1.getComputedLeft()).toBe(110); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(80); + expect(root_child1.getComputedHeight()).toBe(300); + + expect(root_child2.getComputedLeft()).toBe(220); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(80); + expect(root_child2.getComputedHeight()).toBe(300); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(220); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(300); + + expect(root_child1.getComputedLeft()).toBe(110); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(80); + expect(root_child1.getComputedHeight()).toBe(300); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(80); + expect(root_child2.getComputedHeight()).toBe(300); }); test('row_gap_percent_wrapping_with_mixed_flexible_content', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(300); - root.setHeight(300); - root.setGap(Gutter.Column, "10%"); - root.setGap(Gutter.Row, "10%"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexShrink(1); - root_child1.setFlexBasis("0%"); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth("10%"); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(300); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(300); - - expect(root_child2.getComputedLeft()).toBe(270); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(300); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(290); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(300); - - expect(root_child1.getComputedLeft()).toBe(60); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(300); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(300); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setHeight(300); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("10%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(300); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(300); + + expect(root_child2.getComputedLeft()).toBe(270); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(300); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(290); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(300); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(300); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(300); }); test.skip('row_gap_percent_wrapping_with_min_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setMinWidth(300); - root.setGap(Gutter.Column, "10%"); - root.setGap(Gutter.Row, "10%"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(100); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(100); - root_child2.setHeight(100); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setWidth(100); - root_child3.setHeight(100); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setWidth(100); - root_child4.setHeight(100); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(130); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(130); - expect(root_child3.getComputedTop()).toBe(100); - expect(root_child3.getComputedWidth()).toBe(100); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(200); - expect(root_child4.getComputedWidth()).toBe(100); - expect(root_child4.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(200); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(70); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(200); - expect(root_child2.getComputedTop()).toBe(100); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(70); - expect(root_child3.getComputedTop()).toBe(100); - expect(root_child3.getComputedWidth()).toBe(100); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(200); - expect(root_child4.getComputedTop()).toBe(200); - expect(root_child4.getComputedWidth()).toBe(100); - expect(root_child4.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setMinWidth(300); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(100); + root_child3.setHeight(100); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(100); + root_child4.setHeight(100); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(130); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(130); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(200); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(70); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(200); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(200); + expect(root_child4.getComputedTop()).toBe(200); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); }); diff --git a/javascript/tests/generated/YGIntrinsicSizeTest.test.ts b/javascript/tests/generated/YGIntrinsicSizeTest.test.ts index 97f43f46ee..fbf4cca839 100644 --- a/javascript/tests/generated/YGIntrinsicSizeTest.test.ts +++ b/javascript/tests/generated/YGIntrinsicSizeTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<9f68289fe6931c16fc03d23c66a3ac03>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGIntrinsicSizeTest.html */ @@ -30,3136 +30,2731 @@ import { test('contains_inner_text_long_word', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(2000); - root.setHeight(2000); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root.insertChild(root_child0, 0); - root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "LoremipsumdolorsitametconsecteturadipiscingelitSedeleifasdfettortoracauctorFuscerhoncusipsumtemporerosaliquamconsequatPraesentsoda", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(1300); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(700); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(1300); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "LoremipsumdolorsitametconsecteturadipiscingelitSedeleifasdfettortoracauctorFuscerhoncusipsumtemporerosaliquamconsequatPraesentsoda", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1300); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(700); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1300); + expect(root_child0.getComputedHeight()).toBe(10); }); test('contains_inner_text_no_width_no_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(2000); - root.setHeight(2000); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root.insertChild(root_child0, 0); - root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(2000); - expect(root_child0.getComputedHeight()).toBe(70); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(2000); - expect(root_child0.getComputedHeight()).toBe(70); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + expect(root_child0.getComputedHeight()).toBe(70); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + expect(root_child0.getComputedHeight()).toBe(70); }); test('contains_inner_text_no_width_no_height_long_word_in_paragraph', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(2000); - root.setHeight(2000); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root.insertChild(root_child0, 0); - root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus loremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumlorem Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(2000); - expect(root_child0.getComputedHeight()).toBe(70); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(2000); - expect(root_child0.getComputedHeight()).toBe(70); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus loremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumlorem Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + expect(root_child0.getComputedHeight()).toBe(70); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + expect(root_child0.getComputedHeight()).toBe(70); }); test('contains_inner_text_fixed_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(2000); - root.setHeight(2000); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setWidth(100); - root.insertChild(root_child0, 0); - root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(1290); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(1900); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(1290); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setWidth(100); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(1290); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(1900); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(1290); }); test('contains_inner_text_no_width_fixed_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(2000); - root.setHeight(2000); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(2000); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(2000); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + expect(root_child0.getComputedHeight()).toBe(20); }); test('contains_inner_text_fixed_width_fixed_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(2000); - root.setHeight(2000); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setWidth(50); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(1950); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setWidth(50); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(1950); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(20); }); test('contains_inner_text_max_width_max_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(2000); - root.setHeight(2000); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setMaxWidth(50); - root_child0.setMaxHeight(20); - root.insertChild(root_child0, 0); - root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(1950); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setMaxWidth(50); + root_child0.setMaxHeight(20); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(1950); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(20); }); test('contains_inner_text_max_width_max_height_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(2000); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMaxWidth(50); - root.insertChild(root_child0, 0); - root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Column})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(1890); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(1890); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(1890); - - expect(root_child0.getComputedLeft()).toBe(1950); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(1890); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMaxWidth(50); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Column})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(1890); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(1890); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(1890); + + expect(root_child0.getComputedLeft()).toBe(1950); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(1890); }); test('contains_inner_text_max_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(2000); - root.setHeight(2000); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setMaxWidth(100); - root.insertChild(root_child0, 0); - root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(1290); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(1900); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(1290); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setMaxWidth(100); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(1290); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(1900); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(1290); }); test('contains_inner_text_fixed_width_shorter_text', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(2000); - root.setHeight(2000); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setWidth(100); - root.insertChild(root_child0, 0); - root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(1900); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setWidth(100); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(1900); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(20); }); test('contains_inner_text_fixed_height_shorter_text', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(2000); - root.setHeight(2000); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(110); - expect(root_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(1890); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(110); - expect(root_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(110); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(1890); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(110); + expect(root_child0.getComputedHeight()).toBe(100); }); test('contains_inner_text_max_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(2000); - root.setHeight(2000); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setMaxHeight(20); - root.insertChild(root_child0, 0); - root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(2000); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(2000); - expect(root.getComputedHeight()).toBe(2000); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(2000); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setMaxHeight(20); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + expect(root_child0.getComputedHeight()).toBe(20); }); test('max_content_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth("max-content"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(100); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(25); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(175); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(150); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(175); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(125); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(25); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth("max-content"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(175); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(150); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(175); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(125); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(25); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(50); }); test.skip('fit_content_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(90); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setWidth("fit-content"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(100); - root_child0_child1.setHeight(50); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(25); - root_child0_child2.setHeight(50); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(90); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(90); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(-10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(75); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(90); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setWidth("fit-content"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(100); + root_child0_child1.setHeight(50); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(25); + root_child0_child2.setHeight(50); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(90); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(90); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(75); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); }); test('stretch_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setWidth("stretch"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(100); - root_child0_child1.setHeight(50); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(25); - root_child0_child2.setHeight(50); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(50); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(150); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(450); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(350); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(325); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setWidth("stretch"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(100); + root_child0_child1.setHeight(50); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(25); + root_child0_child2.setHeight(50); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(150); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(450); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(350); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(325); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); }); test('max_content_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setHeight("max-content"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(25); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(175); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(150); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(175); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(150); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setHeight("max-content"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(175); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(150); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(175); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(150); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(25); }); test.skip('fit_content_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setHeight(90); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight("fit-content"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(50); - root_child0_child1.setHeight(100); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(50); - root_child0_child2.setHeight(25); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(90); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(175); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(150); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(90); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(175); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(150); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(90); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight("fit-content"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(50); + root_child0_child1.setHeight(100); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(50); + root_child0_child2.setHeight(25); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(175); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(150); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(175); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(150); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); }); test.skip('stretch_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight("stretch"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(50); - root_child0_child1.setHeight(100); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(50); - root_child0_child2.setHeight(25); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(150); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(150); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight("stretch"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(50); + root_child0_child1.setHeight(100); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(50); + root_child0_child2.setHeight(25); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(150); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(150); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); }); test('max_content_flex_basis_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setFlexBasis("max-content"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(25); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(175); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(150); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(175); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(150); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setFlexBasis("max-content"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(175); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(150); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(175); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(150); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(25); }); test.skip('fit_content_flex_basis_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setHeight(90); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setFlexBasis("fit-content"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(50); - root_child0_child1.setHeight(100); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(50); - root_child0_child2.setHeight(25); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(90); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(175); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(150); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(90); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(175); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(150); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(90); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setFlexBasis("fit-content"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(50); + root_child0_child1.setHeight(100); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(50); + root_child0_child2.setHeight(25); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(175); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(150); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(175); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(150); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); }); test('stretch_flex_basis_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexWrap(Wrap.Wrap); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(50); - root_child0_child1.setHeight(100); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(50); - root_child0_child2.setHeight(25); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(175); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(150); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(175); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(150); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexWrap(Wrap.Wrap); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(50); + root_child0_child1.setHeight(100); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(50); + root_child0_child2.setHeight(25); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(175); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(150); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(175); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(150); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); }); test.skip('max_content_flex_basis_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setFlexBasis("max-content"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(100); - root_child1.setHeight(500); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(25); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(600); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(500); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(550); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(600); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(500); - - expect(root_child2.getComputedLeft()).toBe(75); - expect(root_child2.getComputedTop()).toBe(550); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setFlexBasis("max-content"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(500); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(600); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(500); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(550); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(600); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(500); + + expect(root_child2.getComputedLeft()).toBe(75); + expect(root_child2.getComputedTop()).toBe(550); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(50); }); test.skip('fit_content_flex_basis_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(90); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setFlexBasis("fit-content"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(100); - root_child0_child1.setHeight(50); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(25); - root_child0_child2.setHeight(50); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(90); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(90); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(90); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(90); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child0_child0.getComputedLeft()).toBe(40); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(-10); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(65); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(90); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setFlexBasis("fit-content"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(100); + root_child0_child1.setHeight(50); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(25); + root_child0_child2.setHeight(50); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(90); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(90); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child0_child0.getComputedLeft()).toBe(40); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(-10); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(65); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); }); test.skip('stretch_flex_basis_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setFlexWrap(Wrap.Wrap); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(100); - root_child0_child1.setHeight(50); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(25); - root_child0_child2.setHeight(50); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(50); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(150); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(450); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(350); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(325); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(100); + root_child0_child1.setHeight(50); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(25); + root_child0_child2.setHeight(50); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(150); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(450); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(350); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(325); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); }); test.skip('max_content_max_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(200); - root.setMaxWidth("max-content"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(100); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(25); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(175); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(150); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(175); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(125); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(25); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(200); + root.setMaxWidth("max-content"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(175); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(150); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(175); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(125); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(25); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(50); }); test.skip('fit_content_max_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(90); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setWidth(110); - root_child0.setMaxWidth("fit-content"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(100); - root_child0_child1.setHeight(50); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(25); - root_child0_child2.setHeight(50); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(90); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(90); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(-10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(75); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(90); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setWidth(110); + root_child0.setMaxWidth("fit-content"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(100); + root_child0_child1.setHeight(50); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(25); + root_child0_child2.setHeight(50); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(90); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(90); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(75); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); }); test.skip('stretch_max_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setWidth(600); - root_child0.setMaxWidth("stretch"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(100); - root_child0_child1.setHeight(50); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(25); - root_child0_child2.setHeight(50); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(50); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(150); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(450); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(350); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(325); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setWidth(600); + root_child0.setMaxWidth("stretch"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(100); + root_child0_child1.setHeight(50); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(25); + root_child0_child2.setHeight(50); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(150); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(450); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(350); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(325); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); }); test.skip('max_content_min_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setWidth(100); - root.setMinWidth("max-content"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(100); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(25); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(175); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(150); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(175); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(125); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(25); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setMinWidth("max-content"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(175); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(150); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(175); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(125); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(25); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(50); }); test.skip('fit_content_min_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(90); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setWidth(90); - root_child0.setMinWidth("fit-content"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(100); - root_child0_child1.setHeight(50); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(25); - root_child0_child2.setHeight(50); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(90); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(90); - expect(root.getComputedHeight()).toBe(150); - - expect(root_child0.getComputedLeft()).toBe(-10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(75); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(90); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setWidth(90); + root_child0.setMinWidth("fit-content"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(100); + root_child0_child1.setHeight(50); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(25); + root_child0_child2.setHeight(50); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(90); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(90); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(75); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); }); test.skip('stretch_min_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setWidth(400); - root_child0.setMinWidth("stretch"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(100); - root_child0_child1.setHeight(50); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(25); - root_child0_child2.setHeight(50); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(50); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(150); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(450); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(350); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(325); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setWidth(400); + root_child0.setMinWidth("stretch"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(100); + root_child0_child1.setHeight(50); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(25); + root_child0_child2.setHeight(50); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(150); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(450); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(350); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(325); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); }); test.skip('max_content_max_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setHeight(200); - root.setMaxHeight("max-content"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(25); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(175); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(150); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(175); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(150); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setHeight(200); + root.setMaxHeight("max-content"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(175); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(150); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(175); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(150); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(25); }); test.skip('fit_content_max_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setHeight(90); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(110); - root_child0.setMaxHeight("fit-content"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(50); - root_child0_child1.setHeight(100); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(50); - root_child0_child2.setHeight(25); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(90); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(50); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(100); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(90); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(-50); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(-100); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(90); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(110); + root_child0.setMaxHeight("fit-content"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(50); + root_child0_child1.setHeight(100); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(50); + root_child0_child2.setHeight(25); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(100); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(-50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(-100); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); }); test.skip('stretch_max_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(600); - root_child0.setMaxHeight("stretch"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(50); - root_child0_child1.setHeight(100); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(50); - root_child0_child2.setHeight(25); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(150); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(150); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(600); + root_child0.setMaxHeight("stretch"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(50); + root_child0_child1.setHeight(100); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(50); + root_child0_child2.setHeight(25); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(150); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(150); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); }); test.skip('max_content_min_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setFlexWrap(Wrap.Wrap); - root.setHeight(100); - root.setMinHeight("max-content"); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(25); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(100); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(-50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(-100); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setHeight(100); + root.setMinHeight("max-content"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(-50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(-100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(25); }); test.skip('fit_content_min_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setHeight(90); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(90); - root_child0.setMinHeight("fit-content"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(50); - root_child0_child1.setHeight(100); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(50); - root_child0_child2.setHeight(25); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(90); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(50); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(100); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(90); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(-50); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(-100); - expect(root_child0_child2.getComputedTop()).toBe(0); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(90); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(90); + root_child0.setMinHeight("fit-content"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(50); + root_child0_child1.setHeight(100); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(50); + root_child0_child2.setHeight(25); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(100); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(-50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(-100); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); }); test.skip('stretch_min_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexWrap(Wrap.Wrap); - root_child0.setHeight(400); - root_child0.setMinHeight("stretch"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(50); - root_child0_child1.setHeight(100); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setWidth(50); - root_child0_child2.setHeight(25); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(150); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(50); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child2.getComputedLeft()).toBe(0); - expect(root_child0_child2.getComputedTop()).toBe(150); - expect(root_child0_child2.getComputedWidth()).toBe(50); - expect(root_child0_child2.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(400); + root_child0.setMinHeight("stretch"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(50); + root_child0_child1.setHeight(100); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(50); + root_child0_child2.setHeight(25); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(150); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(150); + expect(root_child0_child2.getComputedWidth()).toBe(50); + expect(root_child0_child2.getComputedHeight()).toBe(25); }); test.skip('text_max_content_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("max-content"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0.insertChild(root_child0_child0, 0); - root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(10); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(1140); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(1140); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(10); - - expect(root_child0.getComputedLeft()).toBe(-940); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(1140); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(1140); - expect(root_child0_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("max-content"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0.insertChild(root_child0_child0, 0); + root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(10); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1140); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(1140); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(10); + + expect(root_child0.getComputedLeft()).toBe(-940); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1140); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(1140); + expect(root_child0_child0.getComputedHeight()).toBe(10); }); test.skip('text_stretch_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("stretch"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0.insertChild(root_child0_child0, 0); - root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(20); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(20); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("stretch"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0.insertChild(root_child0_child0, 0); + root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(20); }); test.skip('text_fit_content_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("fit-content"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0.insertChild(root_child0_child0, 0); - root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(30); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(870); - expect(root_child0.getComputedHeight()).toBe(30); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(870); - expect(root_child0_child0.getComputedHeight()).toBe(30); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(30); - - expect(root_child0.getComputedLeft()).toBe(-670); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(870); - expect(root_child0.getComputedHeight()).toBe(30); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(870); - expect(root_child0_child0.getComputedHeight()).toBe(30); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("fit-content"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0.insertChild(root_child0_child0, 0); + root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(870); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(870); + expect(root_child0_child0.getComputedHeight()).toBe(30); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(-670); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(870); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(870); + expect(root_child0_child0.getComputedHeight()).toBe(30); }); test.skip('text_max_content_min_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setMinWidth("max-content"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0.insertChild(root_child0_child0, 0); - root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(10); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(1140); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(1140); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(10); - - expect(root_child0.getComputedLeft()).toBe(-940); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(1140); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(1140); - expect(root_child0_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setMinWidth("max-content"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0.insertChild(root_child0_child0, 0); + root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(10); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1140); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(1140); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(10); + + expect(root_child0.getComputedLeft()).toBe(-940); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1140); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(1140); + expect(root_child0_child0.getComputedHeight()).toBe(10); }); test.skip('text_stretch_min_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(100); - root_child0.setMinWidth("stretch"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0.insertChild(root_child0_child0, 0); - root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(20); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(20); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setMinWidth("stretch"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0.insertChild(root_child0_child0, 0); + root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(20); }); test.skip('text_fit_content_min_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(300); - root_child0.setMinWidth("fit-content"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0.insertChild(root_child0_child0, 0); - root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(30); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(870); - expect(root_child0.getComputedHeight()).toBe(30); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(870); - expect(root_child0_child0.getComputedHeight()).toBe(30); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(30); - - expect(root_child0.getComputedLeft()).toBe(-670); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(870); - expect(root_child0.getComputedHeight()).toBe(30); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(870); - expect(root_child0_child0.getComputedHeight()).toBe(30); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(300); + root_child0.setMinWidth("fit-content"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0.insertChild(root_child0_child0, 0); + root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(870); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(870); + expect(root_child0_child0.getComputedHeight()).toBe(30); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(-670); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(870); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(870); + expect(root_child0_child0.getComputedHeight()).toBe(30); }); test.skip('text_max_content_max_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(2000); - root_child0.setMaxWidth("max-content"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0.insertChild(root_child0_child0, 0); - root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(10); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(1140); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(1140); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(10); - - expect(root_child0.getComputedLeft()).toBe(-940); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(1140); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(1140); - expect(root_child0_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(2000); + root_child0.setMaxWidth("max-content"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0.insertChild(root_child0_child0, 0); + root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(10); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1140); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(1140); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(10); + + expect(root_child0.getComputedLeft()).toBe(-940); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1140); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(1140); + expect(root_child0_child0.getComputedHeight()).toBe(10); }); test.skip('text_stretch_max_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(300); - root_child0.setMaxWidth("stretch"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0.insertChild(root_child0_child0, 0); - root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(20); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(20); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(300); + root_child0.setMaxWidth("stretch"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0.insertChild(root_child0_child0, 0); + root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(20); }); test.skip('text_fit_content_max_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(1000); - root_child0.setMaxWidth("fit-content"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0.insertChild(root_child0_child0, 0); - root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet", flexDirection: FlexDirection.Row})); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(30); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(870); - expect(root_child0.getComputedHeight()).toBe(30); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(870); - expect(root_child0_child0.getComputedHeight()).toBe(30); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(30); - - expect(root_child0.getComputedLeft()).toBe(-670); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(870); - expect(root_child0.getComputedHeight()).toBe(30); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(870); - expect(root_child0_child0.getComputedHeight()).toBe(30); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(1000); + root_child0.setMaxWidth("fit-content"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0.insertChild(root_child0_child0, 0); + root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet", flexDirection: FlexDirection.Row})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(870); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(870); + expect(root_child0_child0.getComputedHeight()).toBe(30); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(-670); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(870); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(870); + expect(root_child0_child0.getComputedHeight()).toBe(30); }); diff --git a/javascript/tests/generated/YGJustifyContentTest.test.ts b/javascript/tests/generated/YGJustifyContentTest.test.ts index 63f814f1a2..3dc5372162 100644 --- a/javascript/tests/generated/YGJustifyContentTest.test.ts +++ b/javascript/tests/generated/YGJustifyContentTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGJustifyContentTest.html */ @@ -30,2121 +30,1851 @@ import { test('justify_content_row_flex_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(10); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(20); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(102); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(92); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(82); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(72); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(102); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(92); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(82); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(72); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); }); test('justify_content_row_flex_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(72); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(82); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(92); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(102); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(10); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(102); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(72); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(82); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(92); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); }); test('justify_content_row_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(36); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(46); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(56); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(102); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(56); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(46); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(36); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(102); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(36); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(46); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(56); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(56); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(46); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(36); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); }); test('justify_content_row_space_between', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.SpaceBetween); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(46); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(92); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(102); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(92); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(46); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(102); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(46); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(92); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(92); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(46); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); }); test('justify_content_row_space_around', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.SpaceAround); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(12); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(46); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(80); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(102); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(46); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(12); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(102); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(12); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(46); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(46); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(12); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); }); test('justify_content_column_flex_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(102); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(102); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(102); - expect(root_child2.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(102); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(10); - expect(root_child1.getComputedWidth()).toBe(102); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(20); - expect(root_child2.getComputedWidth()).toBe(102); - expect(root_child2.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); }); test('justify_content_column_flex_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(72); - expect(root_child0.getComputedWidth()).toBe(102); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(82); - expect(root_child1.getComputedWidth()).toBe(102); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(92); - expect(root_child2.getComputedWidth()).toBe(102); - expect(root_child2.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(72); - expect(root_child0.getComputedWidth()).toBe(102); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(82); - expect(root_child1.getComputedWidth()).toBe(102); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(92); - expect(root_child2.getComputedWidth()).toBe(102); - expect(root_child2.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(72); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(82); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(92); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(72); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(82); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(92); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); }); test('justify_content_column_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(36); - expect(root_child0.getComputedWidth()).toBe(102); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(46); - expect(root_child1.getComputedWidth()).toBe(102); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(56); - expect(root_child2.getComputedWidth()).toBe(102); - expect(root_child2.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(36); - expect(root_child0.getComputedWidth()).toBe(102); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(46); - expect(root_child1.getComputedWidth()).toBe(102); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(56); - expect(root_child2.getComputedWidth()).toBe(102); - expect(root_child2.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(36); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(56); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(36); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(56); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); }); test('justify_content_column_space_between', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.SpaceBetween); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(102); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(46); - expect(root_child1.getComputedWidth()).toBe(102); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(92); - expect(root_child2.getComputedWidth()).toBe(102); - expect(root_child2.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(102); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(46); - expect(root_child1.getComputedWidth()).toBe(102); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(92); - expect(root_child2.getComputedWidth()).toBe(102); - expect(root_child2.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(92); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(92); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); }); test('justify_content_column_space_around', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.SpaceAround); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(12); - expect(root_child0.getComputedWidth()).toBe(102); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(46); - expect(root_child1.getComputedWidth()).toBe(102); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(80); - expect(root_child2.getComputedWidth()).toBe(102); - expect(root_child2.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(12); - expect(root_child0.getComputedWidth()).toBe(102); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(46); - expect(root_child1.getComputedWidth()).toBe(102); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(80); - expect(root_child2.getComputedWidth()).toBe(102); - expect(root_child2.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); }); test('justify_content_row_min_width_and_margin', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setMargin(Edge.Left, 100); - root.setMinWidth(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(100); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(20); - - expect(root_child0.getComputedLeft()).toBe(15); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(100); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(20); - - expect(root_child0.getComputedLeft()).toBe(15); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Left, 100); + root.setMinWidth(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(100); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(15); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(100); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(15); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); }); test('justify_content_row_max_width_and_margin', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setMargin(Edge.Left, 100); - root.setWidth(100); - root.setMaxWidth(80); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(100); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(20); - - expect(root_child0.getComputedLeft()).toBe(30); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(100); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(80); - expect(root.getComputedHeight()).toBe(20); - - expect(root_child0.getComputedLeft()).toBe(30); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Left, 100); + root.setWidth(100); + root.setMaxWidth(80); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(100); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(100); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); }); test('justify_content_column_min_height_and_margin', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setMargin(Edge.Top, 100); - root.setMinHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(100); - expect(root.getComputedWidth()).toBe(20); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(15); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(100); - expect(root.getComputedWidth()).toBe(20); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(15); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Top, 100); + root.setMinHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(100); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(100); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); }); test('justify_content_column_max_height_and_margin', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setMargin(Edge.Top, 100); - root.setHeight(100); - root.setMaxHeight(80); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(100); - expect(root.getComputedWidth()).toBe(20); - expect(root.getComputedHeight()).toBe(80); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(30); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(100); - expect(root.getComputedWidth()).toBe(20); - expect(root.getComputedHeight()).toBe(80); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(30); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Top, 100); + root.setHeight(100); + root.setMaxHeight(80); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(100); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(100); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); }); test('justify_content_column_space_evenly', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.SpaceEvenly); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(18); - expect(root_child0.getComputedWidth()).toBe(102); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(46); - expect(root_child1.getComputedWidth()).toBe(102); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(74); - expect(root_child2.getComputedWidth()).toBe(102); - expect(root_child2.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(18); - expect(root_child0.getComputedWidth()).toBe(102); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(46); - expect(root_child1.getComputedWidth()).toBe(102); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(74); - expect(root_child2.getComputedWidth()).toBe(102); - expect(root_child2.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(74); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(74); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); }); test('justify_content_row_space_evenly', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.SpaceEvenly); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(26); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(51); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(77); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(0); - expect(root_child2.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(77); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(51); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(26); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(0); - expect(root_child2.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(26); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(51); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(77); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(77); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(51); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(26); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(10); }); test('justify_content_min_width_with_padding_child_width_greater_than_parent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setWidth(1000); - root.setHeight(1584); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setAlignContent(Align.Stretch); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0_child0.setJustifyContent(Justify.Center); - root_child0_child0.setAlignContent(Align.Stretch); - root_child0_child0.setPadding(Edge.Left, 100); - root_child0_child0.setPadding(Edge.Right, 100); - root_child0_child0.setMinWidth(400); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0_child0_child0.setAlignContent(Align.Stretch); - root_child0_child0_child0.setWidth(300); - root_child0_child0_child0.setHeight(100); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(1000); - expect(root.getComputedHeight()).toBe(1584); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(1000); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(500); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(300); - expect(root_child0_child0_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(1000); - expect(root.getComputedHeight()).toBe(1584); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(1000); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(500); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(500); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(300); - expect(root_child0_child0_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setWidth(1000); + root.setHeight(1584); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setAlignContent(Align.Stretch); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0.setJustifyContent(Justify.Center); + root_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0.setPadding(Edge.Left, 100); + root_child0_child0.setPadding(Edge.Right, 100); + root_child0_child0.setMinWidth(400); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0_child0.setWidth(300); + root_child0_child0_child0.setHeight(100); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(1000); + expect(root.getComputedHeight()).toBe(1584); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1000); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(500); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(300); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(1000); + expect(root.getComputedHeight()).toBe(1584); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1000); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(500); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(500); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(300); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); }); test('justify_content_min_width_with_padding_child_width_lower_than_parent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignContent(Align.Stretch); - root.setPositionType(PositionType.Absolute); - root.setWidth(1080); - root.setHeight(1584); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setAlignContent(Align.Stretch); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0_child0.setJustifyContent(Justify.Center); - root_child0_child0.setAlignContent(Align.Stretch); - root_child0_child0.setPadding(Edge.Left, 100); - root_child0_child0.setPadding(Edge.Right, 100); - root_child0_child0.setMinWidth(400); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0_child0_child0.setAlignContent(Align.Stretch); - root_child0_child0_child0.setWidth(199); - root_child0_child0_child0.setHeight(100); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(1080); - expect(root.getComputedHeight()).toBe(1584); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(1080); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(400); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(101); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(199); - expect(root_child0_child0_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(1080); - expect(root.getComputedHeight()).toBe(1584); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(1080); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(680); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(400); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(101); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(199); - expect(root_child0_child0_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setWidth(1080); + root.setHeight(1584); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setAlignContent(Align.Stretch); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0.setJustifyContent(Justify.Center); + root_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0.setPadding(Edge.Left, 100); + root_child0_child0.setPadding(Edge.Right, 100); + root_child0_child0.setMinWidth(400); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0_child0.setWidth(199); + root_child0_child0_child0.setHeight(100); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(1080); + expect(root.getComputedHeight()).toBe(1584); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1080); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(400); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(101); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(199); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(1080); + expect(root.getComputedHeight()).toBe(1584); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1080); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(680); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(400); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(101); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(199); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); }); test('justify_content_space_between_indefinite_container_dim_with_free_space', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(300); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setJustifyContent(Justify.SpaceBetween); - root_child0.setMinWidth(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(50); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(50); - root_child0_child1.setHeight(50); - root_child0.insertChild(root_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(150); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(300); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(150); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.SpaceBetween); + root_child0.setMinWidth(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(50); + root_child0_child1.setHeight(50); + root_child0.insertChild(root_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(150); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(150); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(50); }); test('justify_content_flex_start_row_reverse', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(60); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(40); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(20); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(40); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); }); test('justify_content_flex_end_row_reverse', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(20); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(60); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(40); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(20); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(20); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(40); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(20); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); }); test('justify_content_overflow_row_flex_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(40); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(40); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(40); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(80); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(62); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(22); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(-18); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(40); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(62); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(-18); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); }); test('justify_content_overflow_row_flex_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(40); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(40); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(40); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(-18); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(22); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(62); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(40); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(-18); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(62); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); }); test('justify_content_overflow_row_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(40); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(40); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(40); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(-9); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(31); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(71); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(71); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(31); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(-9); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(40); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(-9); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(31); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(71); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(71); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(31); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(-9); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); }); test('justify_content_overflow_row_space_between', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.SpaceBetween); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(40); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(40); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(40); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(80); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(62); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(22); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(-18); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(40); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(62); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(-18); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); }); test('justify_content_overflow_row_space_around', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.SpaceAround); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(40); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(40); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(40); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(80); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(62); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(22); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(-18); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(40); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(62); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(-18); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); }); test('justify_content_overflow_row_space_evenly', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.SpaceEvenly); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(40); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(40); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(40); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(80); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(62); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(22); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(-18); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(40); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(62); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(-18); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); }); test.skip('justify_content_overflow_row_reverse_space_around', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setJustifyContent(Justify.SpaceAround); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(40); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(40); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(40); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(-18); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(22); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(62); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setJustifyContent(Justify.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(40); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(-18); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(62); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); }); test.skip('justify_content_overflow_row_reverse_space_evenly', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.RowReverse); - root.setJustifyContent(Justify.SpaceEvenly); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(40); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(40); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(40); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(-18); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(22); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(62); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setJustifyContent(Justify.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(40); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(-18); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(62); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); }); test('justify_content_overflow_row_space_evenly_auto_margin', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.SpaceEvenly); - root.setPositionType(PositionType.Absolute); - root.setWidth(102); - root.setHeight(102); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Right, 'auto'); - root_child0.setWidth(40); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(40); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(40); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(80); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(102); - expect(root.getComputedHeight()).toBe(102); - - expect(root_child0.getComputedLeft()).toBe(62); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(40); - expect(root_child0.getComputedHeight()).toBe(102); - - expect(root_child1.getComputedLeft()).toBe(22); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(102); - - expect(root_child2.getComputedLeft()).toBe(-18); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(40); - expect(root_child2.getComputedHeight()).toBe(102); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(40); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(62); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(-18); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); }); diff --git a/javascript/tests/generated/YGMarginTest.test.ts b/javascript/tests/generated/YGMarginTest.test.ts index 8046de55d0..a4a7d97144 100644 --- a/javascript/tests/generated/YGMarginTest.test.ts +++ b/javascript/tests/generated/YGMarginTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<3a4aaa192f950239104218a9666654c1>> + * @generated SignedSource<<6da1f5bbb007134b1ba11d7bde816e56>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGMarginTest.html */ @@ -30,1934 +30,1628 @@ import { test('margin_start', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Start, 10); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Start, 10); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); }); test('margin_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Top, 10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); }); test('margin_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setJustifyContent(Justify.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.End, 10); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.End, 10); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); }); test('margin_bottom', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Bottom, 10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(80); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(80); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Bottom, 10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(80); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(80); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); }); test('margin_and_flex_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setMargin(Edge.Start, 10); - root_child0.setMargin(Edge.End, 10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(80); - expect(root_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(80); - expect(root_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMargin(Edge.Start, 10); + root_child0.setMargin(Edge.End, 10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(100); }); test('margin_and_flex_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setMargin(Edge.Top, 10); - root_child0.setMargin(Edge.Bottom, 10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(80); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(80); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMargin(Edge.Top, 10); + root_child0.setMargin(Edge.Bottom, 10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); }); test('margin_and_stretch_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setMargin(Edge.Top, 10); - root_child0.setMargin(Edge.Bottom, 10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(80); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(80); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMargin(Edge.Top, 10); + root_child0.setMargin(Edge.Bottom, 10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); }); test('margin_and_stretch_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setMargin(Edge.Start, 10); - root_child0.setMargin(Edge.End, 10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(80); - expect(root_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(80); - expect(root_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMargin(Edge.Start, 10); + root_child0.setMargin(Edge.End, 10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(100); }); test('margin_with_sibling_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setMargin(Edge.End, 10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(45); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(55); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(45); - expect(root_child1.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(55); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(45); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(45); - expect(root_child1.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMargin(Edge.End, 10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(45); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(55); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(45); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(55); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(45); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(45); + expect(root_child1.getComputedHeight()).toBe(100); }); test('margin_with_sibling_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setMargin(Edge.Bottom, 10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(45); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(55); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(45); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(45); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(55); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(45); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMargin(Edge.Bottom, 10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(45); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(45); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(45); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(45); }); test('margin_auto_bottom', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Bottom, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Bottom, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('margin_auto_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Top, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('margin_auto_bottom_and_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Top, 'auto'); - root_child0.setMargin(Edge.Bottom, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(50); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(50); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 'auto'); + root_child0.setMargin(Edge.Bottom, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('margin_auto_bottom_and_top_justify_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Top, 'auto'); - root_child0.setMargin(Edge.Bottom, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(50); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(50); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(150); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 'auto'); + root_child0.setMargin(Edge.Bottom, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('margin_auto_multiple_children_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Top, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setMargin(Edge.Top, 'auto'); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(25); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(100); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(75); - expect(root_child2.getComputedTop()).toBe(150); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(25); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(100); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(75); - expect(root_child2.getComputedTop()).toBe(150); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Top, 'auto'); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(25); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(75); + expect(root_child2.getComputedTop()).toBe(150); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(25); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(75); + expect(root_child2.getComputedTop()).toBe(150); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); }); test('margin_auto_multiple_children_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Right, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setMargin(Edge.Right, 'auto'); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(75); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(75); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(150); - expect(root_child2.getComputedTop()).toBe(75); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(125); - expect(root_child0.getComputedTop()).toBe(75); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(75); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(75); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Right, 'auto'); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(150); + expect(root_child2.getComputedTop()).toBe(75); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(125); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(75); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); }); test('margin_auto_left_and_right_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 'auto'); - root_child0.setMargin(Edge.Right, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(75); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(150); - expect(root_child1.getComputedTop()).toBe(75); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(75); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(75); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('margin_auto_left_and_right', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 'auto'); - root_child0.setMargin(Edge.Right, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(150); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('margin_auto_start_and_end_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Start, 'auto'); - root_child0.setMargin(Edge.End, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(75); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(150); - expect(root_child1.getComputedTop()).toBe(75); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(75); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(75); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Start, 'auto'); + root_child0.setMargin(Edge.End, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('margin_auto_start_and_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Start, 'auto'); - root_child0.setMargin(Edge.End, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(150); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Start, 'auto'); + root_child0.setMargin(Edge.End, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('margin_auto_left_and_right_column_and_center', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 'auto'); - root_child0.setMargin(Edge.Right, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('margin_auto_left', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('margin_auto_right', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Right, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('margin_auto_left_and_right_stretch', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 'auto'); - root_child0.setMargin(Edge.Right, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(150); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('margin_auto_top_and_bottom_stretch', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Top, 'auto'); - root_child0.setMargin(Edge.Bottom, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(50); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(50); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(150); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 'auto'); + root_child0.setMargin(Edge.Bottom, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('margin_should_not_be_part_of_max_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(250); - root.setHeight(250); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Top, 20); - root_child0.setWidth(100); - root_child0.setHeight(100); - root_child0.setMaxHeight(100); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(250); - expect(root.getComputedHeight()).toBe(250); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(250); - expect(root.getComputedHeight()).toBe(250); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(250); + root.setHeight(250); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 20); + root_child0.setWidth(100); + root_child0.setHeight(100); + root_child0.setMaxHeight(100); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(250); + expect(root.getComputedHeight()).toBe(250); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(250); + expect(root.getComputedHeight()).toBe(250); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); }); test('margin_should_not_be_part_of_max_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(250); - root.setHeight(250); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 20); - root_child0.setWidth(100); - root_child0.setMaxWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(250); - expect(root.getComputedHeight()).toBe(250); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(250); - expect(root.getComputedHeight()).toBe(250); - - expect(root_child0.getComputedLeft()).toBe(150); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(250); + root.setHeight(250); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 20); + root_child0.setWidth(100); + root_child0.setMaxWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(250); + expect(root.getComputedHeight()).toBe(250); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(250); + expect(root.getComputedHeight()).toBe(250); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); }); test('margin_auto_left_right_child_bigger_than_parent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(52); - root.setHeight(52); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 'auto'); - root_child0.setMargin(Edge.Right, 'auto'); - root_child0.setWidth(72); - root_child0.setHeight(72); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(-10); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(72); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(-20); - expect(root_child0.getComputedTop()).toBe(-10); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(72); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(72); + root_child0.setHeight(72); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-20); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); }); test('margin_auto_left_child_bigger_than_parent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(52); - root.setHeight(52); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 'auto'); - root_child0.setWidth(72); - root_child0.setHeight(72); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(-10); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(72); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(-20); - expect(root_child0.getComputedTop()).toBe(-10); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(72); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setWidth(72); + root_child0.setHeight(72); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-20); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); }); test('margin_fix_left_auto_right_child_bigger_than_parent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(52); - root.setHeight(52); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 10); - root_child0.setMargin(Edge.Right, 'auto'); - root_child0.setWidth(72); - root_child0.setHeight(72); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(-10); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(72); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(-20); - expect(root_child0.getComputedTop()).toBe(-10); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(72); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 10); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(72); + root_child0.setHeight(72); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-20); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); }); test('margin_auto_left_fix_right_child_bigger_than_parent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(52); - root.setHeight(52); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 'auto'); - root_child0.setMargin(Edge.Right, 10); - root_child0.setWidth(72); - root_child0.setHeight(72); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(-10); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(72); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(52); - expect(root.getComputedHeight()).toBe(52); - - expect(root_child0.getComputedLeft()).toBe(-30); - expect(root_child0.getComputedTop()).toBe(-10); - expect(root_child0.getComputedWidth()).toBe(72); - expect(root_child0.getComputedHeight()).toBe(72); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 10); + root_child0.setWidth(72); + root_child0.setHeight(72); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-30); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); }); test('margin_auto_top_stretching_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis("0%"); - root_child0.setMargin(Edge.Top, 'auto'); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root_child0.setMargin(Edge.Top, 'auto'); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('margin_auto_left_stretching_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis("0%"); - root_child0.setMargin(Edge.Left, 'auto'); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(200); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(200); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root_child0.setMargin(Edge.Left, 'auto'); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); }); test('margin_auto_overflowing_container', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Bottom, 'auto'); - root_child0.setWidth(50); - root_child0.setHeight(150); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(150); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(150); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(150); - - expect(root_child1.getComputedLeft()).toBe(75); - expect(root_child1.getComputedTop()).toBe(150); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(150); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Bottom, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(150); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(150); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(150); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(150); }); diff --git a/javascript/tests/generated/YGMinMaxDimensionTest.test.ts b/javascript/tests/generated/YGMinMaxDimensionTest.test.ts index dfe3773f5e..7a0a7b064b 100644 --- a/javascript/tests/generated/YGMinMaxDimensionTest.test.ts +++ b/javascript/tests/generated/YGMinMaxDimensionTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<1bd782301afbab34ed3c9a296c3ecaa6>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGMinMaxDimensionTest.html */ @@ -30,1417 +30,1183 @@ import { test('max_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMaxWidth(50); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMaxWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); }); test('max_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root_child0.setMaxHeight(50); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setMaxHeight(50); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(50); }); test.skip('min_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setMinHeight(60); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(60); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(60); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(60); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(60); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMinHeight(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(40); }); test.skip('min_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setMinWidth(60); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(60); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(40); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMinWidth(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(100); }); test('justify_content_min_max', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setMinHeight(100); - root.setMaxHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(60); - root_child0.setHeight(60); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(60); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(40); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(60); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setMinHeight(100); + root.setMaxHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(60); + root_child0.setHeight(60); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); }); test('align_items_min_max', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setMinWidth(100); - root.setMaxWidth(200); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(60); - root_child0.setHeight(60); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(60); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(60); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(100); + root.setMaxWidth(200); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(60); + root_child0.setHeight(60); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); }); test('justify_content_overflow_min_max', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setPositionType(PositionType.Absolute); - root.setMinHeight(100); - root.setMaxHeight(110); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(50); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(50); - root_child2.setHeight(50); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(110); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(-20); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(30); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(80); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(50); - expect(root.getComputedHeight()).toBe(110); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(-20); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(30); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(50); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(80); - expect(root_child2.getComputedWidth()).toBe(50); - expect(root_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setMinHeight(100); + root.setMaxHeight(110); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(110); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(-20); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(110); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(-20); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); }); test('flex_grow_to_min', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setMinHeight(100); - root.setMaxHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexShrink(1); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setMinHeight(100); + root.setMaxHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); }); test('flex_grow_in_at_most_container', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexBasis(0); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(0); - expect(root_child0_child0.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexBasis(0); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); }); test('flex_grow_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis(0); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(0); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(100); }); test('flex_grow_within_constrained_min_max_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setMinHeight(100); - root.setMaxHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setMinHeight(100); + root.setMaxHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(50); }); test('flex_grow_within_max_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setMaxWidth(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setMaxWidth(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(20); }); test('flex_grow_within_constrained_max_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setMaxWidth(300); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setHeight(20); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setMaxWidth(300); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(20); }); test('flex_root_ignored', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setFlexGrow(1); - root.setWidth(100); - root.setMinHeight(100); - root.setMaxHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis(200); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(100); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(200); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(200); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(100); + root.setMinHeight(100); + root.setMaxHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); }); test('flex_grow_root_minimized', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setMinHeight(100); - root.setMaxHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setMinHeight(100); - root_child0.setMaxHeight(500); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexBasis(200); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setHeight(100); - root_child0.insertChild(root_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(300); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(200); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(300); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(300); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(200); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setMinHeight(100); + root.setMaxHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMinHeight(100); + root_child0.setMaxHeight(500); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexBasis(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setHeight(100); + root_child0.insertChild(root_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(300); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(200); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(300); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(200); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(100); }); test('flex_grow_height_maximized', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setMinHeight(100); - root_child0.setMaxHeight(500); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexBasis(200); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setHeight(100); - root_child0.insertChild(root_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(400); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(400); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMinHeight(100); + root_child0.setMaxHeight(500); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexBasis(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setHeight(100); + root_child0.insertChild(root_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(400); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(400); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(100); }); test('flex_grow_within_constrained_min_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setMinWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(50); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(50); - expect(root_child1.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(100); }); test('flex_grow_within_constrained_min_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setMinHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(0); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setMinHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(50); }); test('flex_grow_within_constrained_max_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setMaxWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexShrink(1); - root_child0_child0.setFlexBasis(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth(50); - root_child0.insertChild(root_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child1.getComputedLeft()).toBe(50); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child1.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setMaxWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(50); + root_child0.insertChild(root_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); }); test('flex_grow_within_constrained_max_column', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setMaxHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setHeight(50); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setMaxHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); }); test('child_min_max_width_flexing', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(120); - root.setHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis(0); - root_child0.setMinWidth(60); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexBasis("50%"); - root_child1.setMaxWidth(20); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(120); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(100); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(120); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(20); - expect(root_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(0); + root_child0.setMinWidth(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexBasis("50%"); + root_child1.setMaxWidth(20); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(50); }); test('min_width_overrides_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(50); - root.setMinWidth(100); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(50); + root.setMinWidth(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(0); }); test('max_width_overrides_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setMaxWidth(100); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setMaxWidth(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(0); }); test('min_height_overrides_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setHeight(50); - root.setMinHeight(100); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(50); + root.setMinHeight(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(100); }); test('max_height_overrides_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setHeight(200); - root.setMaxHeight(100); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(200); + root.setMaxHeight(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(100); }); test('min_max_percent_no_width_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMinWidth("10%"); - root_child0.setMaxWidth("10%"); - root_child0.setMinHeight("10%"); - root_child0.setMaxHeight("10%"); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMinWidth("10%"); + root_child0.setMaxWidth("10%"); + root_child0.setMinHeight("10%"); + root_child0.setMaxHeight("10%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); diff --git a/javascript/tests/generated/YGPaddingTest.test.ts b/javascript/tests/generated/YGPaddingTest.test.ts index 474a80821e..31b0c5eaf8 100644 --- a/javascript/tests/generated/YGPaddingTest.test.ts +++ b/javascript/tests/generated/YGPaddingTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<07e65137c3055db0090d46067ec69d5e>> + * @generated SignedSource<<6b248d4e91e352b202a43841c278301e>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGPaddingTest.html */ @@ -30,325 +30,262 @@ import { test('padding_no_size', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 10); - root.setPadding(Edge.Top, 10); - root.setPadding(Edge.Right, 10); - root.setPadding(Edge.Bottom, 10); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(20); - expect(root.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(20); - expect(root.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 10); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 10); + root.setPadding(Edge.Bottom, 10); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(20); }); test('padding_container_match_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 10); - root.setPadding(Edge.Top, 10); - root.setPadding(Edge.Right, 10); - root.setPadding(Edge.Bottom, 10); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(30); - expect(root.getComputedHeight()).toBe(30); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(30); - expect(root.getComputedHeight()).toBe(30); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 10); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 10); + root.setPadding(Edge.Bottom, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(30); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(30); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('padding_flex_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 10); - root.setPadding(Edge.Top, 10); - root.setPadding(Edge.Right, 10); - root.setPadding(Edge.Bottom, 10); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(80); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(80); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 10); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 10); + root.setPadding(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(80); }); test('padding_stretch_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 10); - root.setPadding(Edge.Top, 10); - root.setPadding(Edge.Right, 10); - root.setPadding(Edge.Bottom, 10); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(80); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(10); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(80); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 10); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 10); + root.setPadding(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(10); }); test('padding_center_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Start, 10); - root.setPadding(Edge.End, 20); - root.setPadding(Edge.Bottom, 20); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(40); - expect(root_child0.getComputedTop()).toBe(35); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(35); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Start, 10); + root.setPadding(Edge.End, 20); + root.setPadding(Edge.Bottom, 20); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(35); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(35); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('child_with_padding_align_end', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.FlexEnd); - root.setAlignItems(Align.FlexEnd); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 20); - root_child0.setPadding(Edge.Top, 20); - root_child0.setPadding(Edge.Right, 20); - root_child0.setPadding(Edge.Bottom, 20); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(100); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(100); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.FlexEnd); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 20); + root_child0.setPadding(Edge.Top, 20); + root_child0.setPadding(Edge.Right, 20); + root_child0.setPadding(Edge.Bottom, 20); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); }); test('physical_and_relative_edge_defined', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPadding(Edge.Left, 20); - root.setPadding(Edge.End, 50); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("100%"); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(130); - expect(root_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(150); - expect(root_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 20); + root.setPadding(Edge.End, 50); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(130); + expect(root_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); }); diff --git a/javascript/tests/generated/YGPercentageTest.test.ts b/javascript/tests/generated/YGPercentageTest.test.ts index 4f95fb28cb..7101f5f501 100644 --- a/javascript/tests/generated/YGPercentageTest.test.ts +++ b/javascript/tests/generated/YGPercentageTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<091fb5c6d9004e40211bba58ac19d686>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGPercentageTest.html */ @@ -30,1731 +30,1470 @@ import { test('percentage_width_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("30%"); - root_child0.setHeight("30%"); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(60); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(140); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(60); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("30%"); + root_child0.setHeight("30%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(140); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); }); test('percentage_position_left_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(400); - root.setHeight(400); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPosition(Edge.Left, "10%"); - root_child0.setPosition(Edge.Top, "20%"); - root_child0.setWidth("45%"); - root_child0.setHeight("55%"); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(40); - expect(root_child0.getComputedTop()).toBe(80); - expect(root_child0.getComputedWidth()).toBe(180); - expect(root_child0.getComputedHeight()).toBe(220); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(260); - expect(root_child0.getComputedTop()).toBe(80); - expect(root_child0.getComputedWidth()).toBe(180); - expect(root_child0.getComputedHeight()).toBe(220); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPosition(Edge.Left, "10%"); + root_child0.setPosition(Edge.Top, "20%"); + root_child0.setWidth("45%"); + root_child0.setHeight("55%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(80); + expect(root_child0.getComputedWidth()).toBe(180); + expect(root_child0.getComputedHeight()).toBe(220); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(260); + expect(root_child0.getComputedTop()).toBe(80); + expect(root_child0.getComputedWidth()).toBe(180); + expect(root_child0.getComputedHeight()).toBe(220); }); test('percentage_position_bottom_right', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(500); - root.setHeight(500); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPosition(Edge.Right, "20%"); - root_child0.setPosition(Edge.Bottom, "10%"); - root_child0.setWidth("55%"); - root_child0.setHeight("15%"); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(-100); - expect(root_child0.getComputedTop()).toBe(-50); - expect(root_child0.getComputedWidth()).toBe(275); - expect(root_child0.getComputedHeight()).toBe(75); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(500); - expect(root.getComputedHeight()).toBe(500); - - expect(root_child0.getComputedLeft()).toBe(125); - expect(root_child0.getComputedTop()).toBe(-50); - expect(root_child0.getComputedWidth()).toBe(275); - expect(root_child0.getComputedHeight()).toBe(75); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPosition(Edge.Right, "20%"); + root_child0.setPosition(Edge.Bottom, "10%"); + root_child0.setWidth("55%"); + root_child0.setHeight("15%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(-100); + expect(root_child0.getComputedTop()).toBe(-50); + expect(root_child0.getComputedWidth()).toBe(275); + expect(root_child0.getComputedHeight()).toBe(75); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(125); + expect(root_child0.getComputedTop()).toBe(-50); + expect(root_child0.getComputedWidth()).toBe(275); + expect(root_child0.getComputedHeight()).toBe(75); }); test('percentage_flex_basis', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis("50%"); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexBasis("25%"); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(125); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(125); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(75); - expect(root_child1.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(75); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(125); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(75); - expect(root_child1.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("50%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexBasis("25%"); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(125); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(125); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(75); + expect(root_child1.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(125); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(75); + expect(root_child1.getComputedHeight()).toBe(200); }); test('percentage_flex_basis_cross', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis("50%"); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setFlexBasis("25%"); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(125); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(125); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(75); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(125); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(125); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(75); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("50%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexBasis("25%"); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(125); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(125); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(75); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(125); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(125); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(75); }); test.skip('percentage_flex_basis_cross_min_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setMinHeight("60%"); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(2); - root_child1.setMinHeight("10%"); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(120); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(120); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(80); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(120); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(120); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(80); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMinHeight("60%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(2); + root_child1.setMinHeight("10%"); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(120); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(120); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(80); }); test('percentage_flex_basis_main_max_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis("10%"); - root_child0.setMaxHeight("60%"); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(4); - root_child1.setFlexBasis("10%"); - root_child1.setMaxHeight("20%"); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(52); - expect(root_child0.getComputedHeight()).toBe(120); - - expect(root_child1.getComputedLeft()).toBe(52); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(148); - expect(root_child1.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(148); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(52); - expect(root_child0.getComputedHeight()).toBe(120); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(148); - expect(root_child1.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("10%"); + root_child0.setMaxHeight("60%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(4); + root_child1.setFlexBasis("10%"); + root_child1.setMaxHeight("20%"); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(52); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child1.getComputedLeft()).toBe(52); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(148); + expect(root_child1.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(148); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(52); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(148); + expect(root_child1.getComputedHeight()).toBe(40); }); test('percentage_flex_basis_cross_max_height', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis("10%"); - root_child0.setMaxHeight("60%"); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(4); - root_child1.setFlexBasis("10%"); - root_child1.setMaxHeight("20%"); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(120); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(120); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(40); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(120); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(120); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(40); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("10%"); + root_child0.setMaxHeight("60%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(4); + root_child1.setFlexBasis("10%"); + root_child1.setMaxHeight("20%"); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(120); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(120); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(40); }); test('percentage_flex_basis_main_max_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis("15%"); - root_child0.setMaxWidth("60%"); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(4); - root_child1.setFlexBasis("10%"); - root_child1.setMaxWidth("20%"); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(120); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(120); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(120); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(40); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("15%"); + root_child0.setMaxWidth("60%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(4); + root_child1.setFlexBasis("10%"); + root_child1.setMaxWidth("20%"); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(200); }); test('percentage_flex_basis_cross_max_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis("10%"); - root_child0.setMaxWidth("60%"); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(4); - root_child1.setFlexBasis("15%"); - root_child1.setMaxWidth("20%"); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(120); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(150); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(120); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(160); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(40); - expect(root_child1.getComputedHeight()).toBe(150); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("10%"); + root_child0.setMaxWidth("60%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(4); + root_child1.setFlexBasis("15%"); + root_child1.setMaxWidth("20%"); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(150); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(160); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(150); }); test('percentage_flex_basis_main_min_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis("15%"); - root_child0.setMinWidth("60%"); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(4); - root_child1.setFlexBasis("10%"); - root_child1.setMinWidth("20%"); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(120); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(120); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(80); - expect(root_child1.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(80); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(120); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(80); - expect(root_child1.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("15%"); + root_child0.setMinWidth("60%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(4); + root_child1.setFlexBasis("10%"); + root_child1.setMinWidth("20%"); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(80); + expect(root_child1.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(80); + expect(root_child1.getComputedHeight()).toBe(200); }); test('percentage_flex_basis_cross_min_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis("10%"); - root_child0.setMinWidth("60%"); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(4); - root_child1.setFlexBasis("15%"); - root_child1.setMinWidth("20%"); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(150); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(50); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(150); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("10%"); + root_child0.setMinWidth("60%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(4); + root_child1.setFlexBasis("15%"); + root_child1.setMinWidth("20%"); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(150); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(150); }); test('percentage_multiple_nested_with_padding_margin_and_percentage_values', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis("10%"); - root_child0.setMargin(Edge.Left, 5); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 5); - root_child0.setMargin(Edge.Bottom, 5); - root_child0.setPadding(Edge.Left, 3); - root_child0.setPadding(Edge.Top, 3); - root_child0.setPadding(Edge.Right, 3); - root_child0.setPadding(Edge.Bottom, 3); - root_child0.setMinWidth("60%"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setMargin(Edge.Left, 5); - root_child0_child0.setMargin(Edge.Top, 5); - root_child0_child0.setMargin(Edge.Right, 5); - root_child0_child0.setMargin(Edge.Bottom, 5); - root_child0_child0.setPadding(Edge.Left, "3%"); - root_child0_child0.setPadding(Edge.Top, "3%"); - root_child0_child0.setPadding(Edge.Right, "3%"); - root_child0_child0.setPadding(Edge.Bottom, "3%"); - root_child0_child0.setWidth("50%"); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setMargin(Edge.Left, "5%"); - root_child0_child0_child0.setMargin(Edge.Top, "5%"); - root_child0_child0_child0.setMargin(Edge.Right, "5%"); - root_child0_child0_child0.setMargin(Edge.Bottom, "5%"); - root_child0_child0_child0.setPadding(Edge.Left, 3); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 3); - root_child0_child0_child0.setPadding(Edge.Bottom, 3); - root_child0_child0_child0.setWidth("45%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(4); - root_child1.setFlexBasis("15%"); - root_child1.setMinWidth("20%"); - root.insertChild(root_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(5); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(190); - expect(root_child0.getComputedHeight()).toBe(48); - - expect(root_child0_child0.getComputedLeft()).toBe(8); - expect(root_child0_child0.getComputedTop()).toBe(8); - expect(root_child0_child0.getComputedWidth()).toBe(92); - expect(root_child0_child0.getComputedHeight()).toBe(25); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(10); - expect(root_child0_child0_child0.getComputedTop()).toBe(10); - expect(root_child0_child0_child0.getComputedWidth()).toBe(36); - expect(root_child0_child0_child0.getComputedHeight()).toBe(6); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(58); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(142); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(5); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(190); - expect(root_child0.getComputedHeight()).toBe(48); - - expect(root_child0_child0.getComputedLeft()).toBe(90); - expect(root_child0_child0.getComputedTop()).toBe(8); - expect(root_child0_child0.getComputedWidth()).toBe(92); - expect(root_child0_child0.getComputedHeight()).toBe(25); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(46); - expect(root_child0_child0_child0.getComputedTop()).toBe(10); - expect(root_child0_child0_child0.getComputedWidth()).toBe(36); - expect(root_child0_child0_child0.getComputedHeight()).toBe(6); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(58); - expect(root_child1.getComputedWidth()).toBe(200); - expect(root_child1.getComputedHeight()).toBe(142); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("10%"); + root_child0.setMargin(Edge.Left, 5); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 5); + root_child0.setMargin(Edge.Bottom, 5); + root_child0.setPadding(Edge.Left, 3); + root_child0.setPadding(Edge.Top, 3); + root_child0.setPadding(Edge.Right, 3); + root_child0.setPadding(Edge.Bottom, 3); + root_child0.setMinWidth("60%"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setMargin(Edge.Left, 5); + root_child0_child0.setMargin(Edge.Top, 5); + root_child0_child0.setMargin(Edge.Right, 5); + root_child0_child0.setMargin(Edge.Bottom, 5); + root_child0_child0.setPadding(Edge.Left, "3%"); + root_child0_child0.setPadding(Edge.Top, "3%"); + root_child0_child0.setPadding(Edge.Right, "3%"); + root_child0_child0.setPadding(Edge.Bottom, "3%"); + root_child0_child0.setWidth("50%"); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setMargin(Edge.Left, "5%"); + root_child0_child0_child0.setMargin(Edge.Top, "5%"); + root_child0_child0_child0.setMargin(Edge.Right, "5%"); + root_child0_child0_child0.setMargin(Edge.Bottom, "5%"); + root_child0_child0_child0.setPadding(Edge.Left, 3); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 3); + root_child0_child0_child0.setPadding(Edge.Bottom, 3); + root_child0_child0_child0.setWidth("45%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(4); + root_child1.setFlexBasis("15%"); + root_child1.setMinWidth("20%"); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(190); + expect(root_child0.getComputedHeight()).toBe(48); + + expect(root_child0_child0.getComputedLeft()).toBe(8); + expect(root_child0_child0.getComputedTop()).toBe(8); + expect(root_child0_child0.getComputedWidth()).toBe(92); + expect(root_child0_child0.getComputedHeight()).toBe(25); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0_child0.getComputedWidth()).toBe(36); + expect(root_child0_child0_child0.getComputedHeight()).toBe(6); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(58); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(142); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(190); + expect(root_child0.getComputedHeight()).toBe(48); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(8); + expect(root_child0_child0.getComputedWidth()).toBe(92); + expect(root_child0_child0.getComputedHeight()).toBe(25); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(46); + expect(root_child0_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0_child0.getComputedWidth()).toBe(36); + expect(root_child0_child0_child0.getComputedHeight()).toBe(6); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(58); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(142); }); test('percentage_margin_should_calculate_based_only_on_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setMargin(Edge.Left, "10%"); - root_child0.setMargin(Edge.Top, "10%"); - root_child0.setMargin(Edge.Right, "10%"); - root_child0.setMargin(Edge.Bottom, "10%"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(160); - expect(root_child0.getComputedHeight()).toBe(60); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(20); - expect(root_child0.getComputedTop()).toBe(20); - expect(root_child0.getComputedWidth()).toBe(160); - expect(root_child0.getComputedHeight()).toBe(60); - - expect(root_child0_child0.getComputedLeft()).toBe(150); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMargin(Edge.Left, "10%"); + root_child0.setMargin(Edge.Top, "10%"); + root_child0.setMargin(Edge.Right, "10%"); + root_child0.setMargin(Edge.Bottom, "10%"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(160); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(160); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child0_child0.getComputedLeft()).toBe(150); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); }); test('percentage_padding_should_calculate_based_only_on_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setPadding(Edge.Left, "10%"); - root_child0.setPadding(Edge.Top, "10%"); - root_child0.setPadding(Edge.Right, "10%"); - root_child0.setPadding(Edge.Bottom, "10%"); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(10); - root_child0_child0.setHeight(10); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(20); - expect(root_child0_child0.getComputedTop()).toBe(20); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(170); - expect(root_child0_child0.getComputedTop()).toBe(20); - expect(root_child0_child0.getComputedWidth()).toBe(10); - expect(root_child0_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setPadding(Edge.Left, "10%"); + root_child0.setPadding(Edge.Top, "10%"); + root_child0.setPadding(Edge.Right, "10%"); + root_child0.setPadding(Edge.Bottom, "10%"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(170); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); }); test('percentage_absolute_position', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPosition(Edge.Left, "30%"); - root_child0.setPosition(Edge.Top, "10%"); - root_child0.setWidth(10); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(60); - expect(root_child0.getComputedTop()).toBe(10); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, "30%"); + root_child0.setPosition(Edge.Top, "10%"); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); }); test('percentage_width_height_undefined_parent_size', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("50%"); - root_child0.setHeight("50%"); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(0); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(0); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(0); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight("50%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(0); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(0); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); }); test('percent_within_flex_grow', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(350); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setWidth("100%"); - root_child1.insertChild(root_child1_child0, 0); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth(100); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(350); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(100); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(150); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(150); - expect(root_child1_child0.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(250); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(350); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(250); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(100); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(150); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(150); - expect(root_child1_child0.getComputedHeight()).toBe(0); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(350); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth("100%"); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(350); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(150); + expect(root_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(250); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(350); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(250); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(150); + expect(root_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); }); test('percentage_container_in_wrapping_container', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setJustifyContent(Justify.Center); - root.setAlignItems(Align.Center); - root.setPositionType(PositionType.Absolute); - root.setWidth(200); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.Row); - root_child0_child0.setJustifyContent(Justify.Center); - root_child0_child0.setWidth("100%"); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child1 = Yoga.Node.create(config); - root_child0_child0_child1.setWidth(50); - root_child0_child0_child1.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(75); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(50); - expect(root_child0_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child0_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(75); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child0_child1.getComputedWidth()).toBe(50); - expect(root_child0_child0_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0.setJustifyContent(Justify.Center); + root_child0_child0.setWidth("100%"); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setWidth(50); + root_child0_child0_child1.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child0_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child0_child1.getComputedHeight()).toBe(50); }); test('percent_absolute_position', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(60); - root.setHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setPosition(Edge.Left, "50%"); - root_child0.setWidth("100%"); - root_child0.setHeight(50); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("100%"); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setWidth("100%"); - root_child0.insertChild(root_child0_child1, 1); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(30); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(60); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(60); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(60); - expect(root_child0_child1.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(30); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(60); - expect(root_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(60); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(-60); - expect(root_child0_child1.getComputedTop()).toBe(0); - expect(root_child0_child1.getComputedWidth()).toBe(60); - expect(root_child0_child1.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, "50%"); + root_child0.setWidth("100%"); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("100%"); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("100%"); + root_child0.insertChild(root_child0_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(60); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(60); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(60); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(60); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(-60); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(60); + expect(root_child0_child1.getComputedHeight()).toBe(50); }); test('percent_of_minmax_main', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setMinWidth(60); - root.setMaxWidth(60); - root.setHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("50%"); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(30); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(60); + root.setMaxWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); }); test.skip('percent_of_min_main', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setMinWidth(60); - root.setHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("50%"); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(30); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); }); test.skip('percent_of_min_main_multiple', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setMinWidth(60); - root.setHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("50%"); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setWidth("50%"); - root_child1.setHeight(20); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setWidth("50%"); - root_child2.setHeight(20); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(30); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(60); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(30); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(20); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(30); - expect(root_child1.getComputedHeight()).toBe(20); - - expect(root_child2.getComputedLeft()).toBe(-30); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(30); - expect(root_child2.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("50%"); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("50%"); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(-30); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(20); }); test.skip('percent_of_max_main', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setMaxWidth(60); - root.setHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("50%"); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setMaxWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(20); }); test('percent_of_minmax_cross_stretched', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setMinWidth(60); - root.setMaxWidth(60); - root.setHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("50%"); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(30); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(60); + root.setMaxWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); }); test('percent_absolute_of_minmax_cross_stretched', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setMinWidth(60); - root.setMaxWidth(60); - root.setHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setWidth("50%"); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(30); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(60); + root.setMaxWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); }); test('percent_of_minmax_cross_unstretched', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setMinWidth(60); - root.setMaxWidth(60); - root.setHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("50%"); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(30); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(60); + root.setMaxWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); }); test.skip('percent_of_min_cross_unstretched', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setMinWidth(60); - root.setHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("50%"); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(60); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(30); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(30); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); }); test('percent_of_max_cross_unstretched', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setAlignItems(Align.FlexStart); - root.setPositionType(PositionType.Absolute); - root.setMaxWidth(60); - root.setHeight(50); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth("50%"); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(20); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(0); - expect(root.getComputedHeight()).toBe(50); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(0); - expect(root_child0.getComputedHeight()).toBe(20); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setMaxWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(20); }); diff --git a/javascript/tests/generated/YGRoundingTest.test.ts b/javascript/tests/generated/YGRoundingTest.test.ts index ca653f138c..2ec784f77b 100644 --- a/javascript/tests/generated/YGRoundingTest.test.ts +++ b/javascript/tests/generated/YGRoundingTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<8119d2703019b25513720167cb4dea4e>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGRoundingTest.html */ @@ -30,1132 +30,1015 @@ import { test('rounding_flex_basis_flex_grow_row_width_of_100', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(33); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(33); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(34); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(67); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(33); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(67); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(33); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(33); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(34); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(33); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(33); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(33); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(34); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(67); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(33); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(67); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(33); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(33); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(34); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(33); + expect(root_child2.getComputedHeight()).toBe(100); }); test('rounding_flex_basis_flex_grow_row_prime_number_width', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(113); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root.insertChild(root_child2, 2); - - const root_child3 = Yoga.Node.create(config); - root_child3.setFlexGrow(1); - root.insertChild(root_child3, 3); - - const root_child4 = Yoga.Node.create(config); - root_child4.setFlexGrow(1); - root.insertChild(root_child4, 4); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(113); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(23); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(23); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(22); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(45); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(23); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(68); - expect(root_child3.getComputedTop()).toBe(0); - expect(root_child3.getComputedWidth()).toBe(22); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(90); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(23); - expect(root_child4.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(113); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(90); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(23); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(68); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(22); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(45); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(23); - expect(root_child2.getComputedHeight()).toBe(100); - - expect(root_child3.getComputedLeft()).toBe(23); - expect(root_child3.getComputedTop()).toBe(0); - expect(root_child3.getComputedWidth()).toBe(22); - expect(root_child3.getComputedHeight()).toBe(100); - - expect(root_child4.getComputedLeft()).toBe(0); - expect(root_child4.getComputedTop()).toBe(0); - expect(root_child4.getComputedWidth()).toBe(23); - expect(root_child4.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(113); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setFlexGrow(1); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setFlexGrow(1); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(113); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(23); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(23); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(22); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(45); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(23); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(68); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(22); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(90); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(23); + expect(root_child4.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(113); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(23); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(68); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(22); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(45); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(23); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(23); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(22); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(23); + expect(root_child4.getComputedHeight()).toBe(100); }); test('rounding_flex_basis_flex_shrink_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(101); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis(100); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexBasis(25); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexBasis(25); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(101); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(51); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(51); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(76); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(101); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(50); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(51); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child1.getComputedLeft()).toBe(25); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(25); - expect(root_child1.getComputedHeight()).toBe(100); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(25); - expect(root_child2.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(101); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexBasis(25); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexBasis(25); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(101); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(51); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(51); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(76); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(101); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(51); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(25); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(100); }); test('rounding_flex_basis_overrides_main_size', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(113); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis(50); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(113); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(64); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(64); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(89); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(24); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(113); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(64); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(64); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(89); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(24); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(113); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(64); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(24); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(64); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(24); }); test('rounding_total_fractial', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(87.4); - root.setHeight(113.4); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(0.7); - root_child0.setFlexBasis(50.3); - root_child0.setHeight(20.3); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1.6); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1.1); - root_child2.setHeight(10.7); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(87); - expect(root.getComputedHeight()).toBe(113); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(87); - expect(root_child0.getComputedHeight()).toBe(59); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(59); - expect(root_child1.getComputedWidth()).toBe(87); - expect(root_child1.getComputedHeight()).toBe(30); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(89); - expect(root_child2.getComputedWidth()).toBe(87); - expect(root_child2.getComputedHeight()).toBe(24); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(87); - expect(root.getComputedHeight()).toBe(113); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(87); - expect(root_child0.getComputedHeight()).toBe(59); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(59); - expect(root_child1.getComputedWidth()).toBe(87); - expect(root_child1.getComputedHeight()).toBe(30); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(89); - expect(root_child2.getComputedWidth()).toBe(87); - expect(root_child2.getComputedHeight()).toBe(24); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(87.4); + root.setHeight(113.4); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(0.7); + root_child0.setFlexBasis(50.3); + root_child0.setHeight(20.3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1.6); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1.1); + root_child2.setHeight(10.7); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(87); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(87); + expect(root_child0.getComputedHeight()).toBe(59); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(59); + expect(root_child1.getComputedWidth()).toBe(87); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(87); + expect(root_child2.getComputedHeight()).toBe(24); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(87); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(87); + expect(root_child0.getComputedHeight()).toBe(59); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(59); + expect(root_child1.getComputedWidth()).toBe(87); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(87); + expect(root_child2.getComputedHeight()).toBe(24); }); test('rounding_total_fractial_nested', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(87.4); - root.setHeight(113.4); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(0.7); - root_child0.setFlexBasis(50.3); - root_child0.setHeight(20.3); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexBasis(0.3); - root_child0_child0.setPosition(Edge.Bottom, 13.3); - root_child0_child0.setHeight(9.9); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setFlexGrow(4); - root_child0_child1.setFlexBasis(0.3); - root_child0_child1.setPosition(Edge.Top, 13.3); - root_child0_child1.setHeight(1.1); - root_child0.insertChild(root_child0_child1, 1); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1.6); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1.1); - root_child2.setHeight(10.7); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(87); - expect(root.getComputedHeight()).toBe(113); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(87); - expect(root_child0.getComputedHeight()).toBe(59); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(-13); - expect(root_child0_child0.getComputedWidth()).toBe(87); - expect(root_child0_child0.getComputedHeight()).toBe(12); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(25); - expect(root_child0_child1.getComputedWidth()).toBe(87); - expect(root_child0_child1.getComputedHeight()).toBe(47); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(59); - expect(root_child1.getComputedWidth()).toBe(87); - expect(root_child1.getComputedHeight()).toBe(30); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(89); - expect(root_child2.getComputedWidth()).toBe(87); - expect(root_child2.getComputedHeight()).toBe(24); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(87); - expect(root.getComputedHeight()).toBe(113); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(87); - expect(root_child0.getComputedHeight()).toBe(59); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(-13); - expect(root_child0_child0.getComputedWidth()).toBe(87); - expect(root_child0_child0.getComputedHeight()).toBe(12); - - expect(root_child0_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1.getComputedTop()).toBe(25); - expect(root_child0_child1.getComputedWidth()).toBe(87); - expect(root_child0_child1.getComputedHeight()).toBe(47); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(59); - expect(root_child1.getComputedWidth()).toBe(87); - expect(root_child1.getComputedHeight()).toBe(30); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(89); - expect(root_child2.getComputedWidth()).toBe(87); - expect(root_child2.getComputedHeight()).toBe(24); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(87.4); + root.setHeight(113.4); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(0.7); + root_child0.setFlexBasis(50.3); + root_child0.setHeight(20.3); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexBasis(0.3); + root_child0_child0.setPosition(Edge.Bottom, 13.3); + root_child0_child0.setHeight(9.9); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setFlexGrow(4); + root_child0_child1.setFlexBasis(0.3); + root_child0_child1.setPosition(Edge.Top, 13.3); + root_child0_child1.setHeight(1.1); + root_child0.insertChild(root_child0_child1, 1); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1.6); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1.1); + root_child2.setHeight(10.7); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(87); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(87); + expect(root_child0.getComputedHeight()).toBe(59); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(-13); + expect(root_child0_child0.getComputedWidth()).toBe(87); + expect(root_child0_child0.getComputedHeight()).toBe(12); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(25); + expect(root_child0_child1.getComputedWidth()).toBe(87); + expect(root_child0_child1.getComputedHeight()).toBe(47); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(59); + expect(root_child1.getComputedWidth()).toBe(87); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(87); + expect(root_child2.getComputedHeight()).toBe(24); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(87); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(87); + expect(root_child0.getComputedHeight()).toBe(59); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(-13); + expect(root_child0_child0.getComputedWidth()).toBe(87); + expect(root_child0_child0.getComputedHeight()).toBe(12); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(25); + expect(root_child0_child1.getComputedWidth()).toBe(87); + expect(root_child0_child1.getComputedHeight()).toBe(47); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(59); + expect(root_child1.getComputedWidth()).toBe(87); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(87); + expect(root_child2.getComputedHeight()).toBe(24); }); test('rounding_fractial_input_1', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(113.4); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis(50); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(113); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(64); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(64); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(89); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(24); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(113); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(64); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(64); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(89); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(24); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(113.4); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(64); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(24); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(64); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(24); }); test('rounding_fractial_input_2', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(113.6); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis(50); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(114); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(65); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(65); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(24); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(89); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(114); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(65); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(65); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(24); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(89); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(113.6); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(114); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(24); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(114); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(24); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(25); }); test('rounding_fractial_input_3', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPosition(Edge.Top, 0.3); - root.setWidth(100); - root.setHeight(113.4); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis(50); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(114); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(65); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(64); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(24); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(89); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(25); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(114); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(65); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(64); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(24); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(89); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(25); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPosition(Edge.Top, 0.3); + root.setWidth(100); + root.setHeight(113.4); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(114); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(24); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(114); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(24); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(25); }); test('rounding_fractial_input_4', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setPosition(Edge.Top, 0.7); - root.setWidth(100); - root.setHeight(113.4); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis(50); - root_child0.setHeight(20); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(1); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(113); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(64); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(64); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(89); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(24); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(1); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(113); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(64); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(64); - expect(root_child1.getComputedWidth()).toBe(100); - expect(root_child1.getComputedHeight()).toBe(25); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(89); - expect(root_child2.getComputedWidth()).toBe(100); - expect(root_child2.getComputedHeight()).toBe(24); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPosition(Edge.Top, 0.7); + root.setWidth(100); + root.setHeight(113.4); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(1); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(64); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(24); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(1); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(64); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(24); }); test('rounding_inner_node_controversy_horizontal', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setHeight(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setHeight(10); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setFlexGrow(1); - root_child1_child0.setHeight(10); - root_child1.insertChild(root_child1_child0, 0); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setHeight(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(10); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(107); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(107); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(106); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(106); - expect(root_child1_child0.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(213); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(107); - expect(root_child2.getComputedHeight()).toBe(10); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(320); - expect(root.getComputedHeight()).toBe(10); - - expect(root_child0.getComputedLeft()).toBe(213); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(107); - expect(root_child0.getComputedHeight()).toBe(10); - - expect(root_child1.getComputedLeft()).toBe(107); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(106); - expect(root_child1.getComputedHeight()).toBe(10); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(106); - expect(root_child1_child0.getComputedHeight()).toBe(10); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(107); - expect(root_child2.getComputedHeight()).toBe(10); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setFlexGrow(1); + root_child1_child0.setHeight(10); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(10); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(107); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(107); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(106); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(106); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(213); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(107); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(10); + + expect(root_child0.getComputedLeft()).toBe(213); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(107); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(107); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(106); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(106); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(107); + expect(root_child2.getComputedHeight()).toBe(10); }); test('rounding_inner_node_controversy_vertical', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setWidth(10); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setWidth(10); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setFlexGrow(1); - root_child1_child0.setWidth(10); - root_child1.insertChild(root_child1_child0, 0); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setWidth(10); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(10); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(107); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(107); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(106); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(10); - expect(root_child1_child0.getComputedHeight()).toBe(106); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(213); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(107); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(10); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(10); - expect(root_child0.getComputedHeight()).toBe(107); - - expect(root_child1.getComputedLeft()).toBe(0); - expect(root_child1.getComputedTop()).toBe(107); - expect(root_child1.getComputedWidth()).toBe(10); - expect(root_child1.getComputedHeight()).toBe(106); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(10); - expect(root_child1_child0.getComputedHeight()).toBe(106); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(213); - expect(root_child2.getComputedWidth()).toBe(10); - expect(root_child2.getComputedHeight()).toBe(107); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setFlexGrow(1); + root_child1_child0.setWidth(10); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(10); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(107); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(107); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(106); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(10); + expect(root_child1_child0.getComputedHeight()).toBe(106); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(107); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(10); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(107); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(107); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(106); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(10); + expect(root_child1_child0.getComputedHeight()).toBe(106); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(107); }); test('rounding_inner_node_controversy_combined', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setFlexDirection(FlexDirection.Row); - root.setPositionType(PositionType.Absolute); - root.setWidth(640); - root.setHeight(320); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexGrow(1); - root_child0.setHeight("100%"); - root.insertChild(root_child0, 0); - - const root_child1 = Yoga.Node.create(config); - root_child1.setFlexGrow(1); - root_child1.setHeight("100%"); - root.insertChild(root_child1, 1); - - const root_child1_child0 = Yoga.Node.create(config); - root_child1_child0.setFlexGrow(1); - root_child1_child0.setWidth("100%"); - root_child1.insertChild(root_child1_child0, 0); - - const root_child1_child1 = Yoga.Node.create(config); - root_child1_child1.setFlexGrow(1); - root_child1_child1.setWidth("100%"); - root_child1.insertChild(root_child1_child1, 1); - - const root_child1_child1_child0 = Yoga.Node.create(config); - root_child1_child1_child0.setFlexGrow(1); - root_child1_child1_child0.setWidth("100%"); - root_child1_child1.insertChild(root_child1_child1_child0, 0); - - const root_child1_child2 = Yoga.Node.create(config); - root_child1_child2.setFlexGrow(1); - root_child1_child2.setWidth("100%"); - root_child1.insertChild(root_child1_child2, 2); - - const root_child2 = Yoga.Node.create(config); - root_child2.setFlexGrow(1); - root_child2.setHeight("100%"); - root.insertChild(root_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(640); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(213); - expect(root_child0.getComputedHeight()).toBe(320); - - expect(root_child1.getComputedLeft()).toBe(213); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(214); - expect(root_child1.getComputedHeight()).toBe(320); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(214); - expect(root_child1_child0.getComputedHeight()).toBe(107); - - expect(root_child1_child1.getComputedLeft()).toBe(0); - expect(root_child1_child1.getComputedTop()).toBe(107); - expect(root_child1_child1.getComputedWidth()).toBe(214); - expect(root_child1_child1.getComputedHeight()).toBe(106); - - expect(root_child1_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child1_child0.getComputedWidth()).toBe(214); - expect(root_child1_child1_child0.getComputedHeight()).toBe(106); - - expect(root_child1_child2.getComputedLeft()).toBe(0); - expect(root_child1_child2.getComputedTop()).toBe(213); - expect(root_child1_child2.getComputedWidth()).toBe(214); - expect(root_child1_child2.getComputedHeight()).toBe(107); - - expect(root_child2.getComputedLeft()).toBe(427); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(213); - expect(root_child2.getComputedHeight()).toBe(320); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(640); - expect(root.getComputedHeight()).toBe(320); - - expect(root_child0.getComputedLeft()).toBe(427); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(213); - expect(root_child0.getComputedHeight()).toBe(320); - - expect(root_child1.getComputedLeft()).toBe(213); - expect(root_child1.getComputedTop()).toBe(0); - expect(root_child1.getComputedWidth()).toBe(214); - expect(root_child1.getComputedHeight()).toBe(320); - - expect(root_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child0.getComputedWidth()).toBe(214); - expect(root_child1_child0.getComputedHeight()).toBe(107); - - expect(root_child1_child1.getComputedLeft()).toBe(0); - expect(root_child1_child1.getComputedTop()).toBe(107); - expect(root_child1_child1.getComputedWidth()).toBe(214); - expect(root_child1_child1.getComputedHeight()).toBe(106); - - expect(root_child1_child1_child0.getComputedLeft()).toBe(0); - expect(root_child1_child1_child0.getComputedTop()).toBe(0); - expect(root_child1_child1_child0.getComputedWidth()).toBe(214); - expect(root_child1_child1_child0.getComputedHeight()).toBe(106); - - expect(root_child1_child2.getComputedLeft()).toBe(0); - expect(root_child1_child2.getComputedTop()).toBe(213); - expect(root_child1_child2.getComputedWidth()).toBe(214); - expect(root_child1_child2.getComputedHeight()).toBe(107); - - expect(root_child2.getComputedLeft()).toBe(0); - expect(root_child2.getComputedTop()).toBe(0); - expect(root_child2.getComputedWidth()).toBe(213); - expect(root_child2.getComputedHeight()).toBe(320); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(640); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setFlexGrow(1); + root_child1_child0.setWidth("100%"); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setFlexGrow(1); + root_child1_child1.setWidth("100%"); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child1_child0 = Yoga.Node.create(config); + root_child1_child1_child0.setFlexGrow(1); + root_child1_child1_child0.setWidth("100%"); + root_child1_child1.insertChild(root_child1_child1_child0, 0); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setFlexGrow(1); + root_child1_child2.setWidth("100%"); + root_child1.insertChild(root_child1_child2, 2); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(640); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(213); + expect(root_child0.getComputedHeight()).toBe(320); + + expect(root_child1.getComputedLeft()).toBe(213); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(214); + expect(root_child1.getComputedHeight()).toBe(320); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(214); + expect(root_child1_child0.getComputedHeight()).toBe(107); + + expect(root_child1_child1.getComputedLeft()).toBe(0); + expect(root_child1_child1.getComputedTop()).toBe(107); + expect(root_child1_child1.getComputedWidth()).toBe(214); + expect(root_child1_child1.getComputedHeight()).toBe(106); + + expect(root_child1_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child1_child0.getComputedWidth()).toBe(214); + expect(root_child1_child1_child0.getComputedHeight()).toBe(106); + + expect(root_child1_child2.getComputedLeft()).toBe(0); + expect(root_child1_child2.getComputedTop()).toBe(213); + expect(root_child1_child2.getComputedWidth()).toBe(214); + expect(root_child1_child2.getComputedHeight()).toBe(107); + + expect(root_child2.getComputedLeft()).toBe(427); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(213); + expect(root_child2.getComputedHeight()).toBe(320); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(640); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(427); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(213); + expect(root_child0.getComputedHeight()).toBe(320); + + expect(root_child1.getComputedLeft()).toBe(213); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(214); + expect(root_child1.getComputedHeight()).toBe(320); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(214); + expect(root_child1_child0.getComputedHeight()).toBe(107); + + expect(root_child1_child1.getComputedLeft()).toBe(0); + expect(root_child1_child1.getComputedTop()).toBe(107); + expect(root_child1_child1.getComputedWidth()).toBe(214); + expect(root_child1_child1.getComputedHeight()).toBe(106); + + expect(root_child1_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child1_child0.getComputedWidth()).toBe(214); + expect(root_child1_child1_child0.getComputedHeight()).toBe(106); + + expect(root_child1_child2.getComputedLeft()).toBe(0); + expect(root_child1_child2.getComputedTop()).toBe(213); + expect(root_child1_child2.getComputedWidth()).toBe(214); + expect(root_child1_child2.getComputedHeight()).toBe(107); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(213); + expect(root_child2.getComputedHeight()).toBe(320); }); diff --git a/javascript/tests/generated/YGSizeOverflowTest.test.ts b/javascript/tests/generated/YGSizeOverflowTest.test.ts index 325dd26db1..c9ba2b2fca 100644 --- a/javascript/tests/generated/YGSizeOverflowTest.test.ts +++ b/javascript/tests/generated/YGSizeOverflowTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGSizeOverflowTest.html */ @@ -30,178 +30,151 @@ import { test('nested_overflowing_child', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(200); - root_child0_child0.setHeight(200); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(-100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(-100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); }); test('nested_overflowing_child_in_constraint_parent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(200); - root_child0_child0.setHeight(200); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0.getComputedLeft()).toBe(-100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(-100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); }); test('parent_wrap_child_size_overflowing_parent', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - root.setWidth(100); - root.setHeight(100); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(100); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(200); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(200); }); diff --git a/javascript/tests/generated/YGStaticPositionTest.test.ts b/javascript/tests/generated/YGStaticPositionTest.test.ts index 0c2bd37327..de6c7f730d 100644 --- a/javascript/tests/generated/YGStaticPositionTest.test.ts +++ b/javascript/tests/generated/YGStaticPositionTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<95e7839c3f11e06cd1e1fc86104d6813>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html */ @@ -30,6309 +30,5751 @@ import { test('static_position_insets_have_no_effect_left_top', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Static); - root_child0.setPosition(Edge.Left, 50); - root_child0.setPosition(Edge.Top, 50); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Static); + root_child0.setPosition(Edge.Left, 50); + root_child0.setPosition(Edge.Top, 50); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); }); test('static_position_insets_have_no_effect_right_bottom', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Static); - root_child0.setPosition(Edge.Right, 50); - root_child0.setPosition(Edge.Bottom, 50); - root_child0.setWidth(100); - root_child0.setHeight(100); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(100); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(100); - expect(root_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Static); + root_child0.setPosition(Edge.Right, 50); + root_child0.setPosition(Edge.Bottom, 50); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); }); test('static_position_absolute_child_insets_relative_to_positioned_ancestor', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 100); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Left, 50); - root_child0_child0_child0.setPosition(Edge.Top, 50); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 100); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, 50); + root_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_absolute_child_insets_relative_to_positioned_ancestor_row_reverse', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Left, 50); - root_child0_child0_child0.setPosition(Edge.Top, 50); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, 50); + root_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_row_reverse', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Left, 50); - root_child0_child0_child0.setPosition(Edge.Top, 50); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, 50); + root_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_absolute_child_insets_relative_to_positioned_ancestor_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Top, 50); - root_child0_child0_child0.setPosition(Edge.Right, 50); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0.setPosition(Edge.Right, 50); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_row', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.Row); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Top, 50); - root_child0_child0_child0.setPosition(Edge.Right, 50); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0.setPosition(Edge.Right, 50); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_absolute_child_insets_relative_to_positioned_ancestor_column_reverse', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Top, 50); - root_child0_child0_child0.setPosition(Edge.Right, 50); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0_child0.getComputedTop()).toBe(-50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(-50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0.setPosition(Edge.Right, 50); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_column_reverse', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Top, 50); - root_child0_child0_child0.setPosition(Edge.Right, 50); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0_child0.getComputedTop()).toBe(-50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(-50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0.setPosition(Edge.Right, 50); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_absolute_child_insets_relative_to_positioned_ancestor_deep', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 100); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Static); - root_child0_child0_child0.setMargin(Edge.Left, 100); - root_child0_child0_child0.setWidth(100); - root_child0_child0_child0.setHeight(100); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0.setPositionType(PositionType.Static); - root_child0_child0_child0_child0.setMargin(Edge.Left, 100); - root_child0_child0_child0_child0.setWidth(100); - root_child0_child0_child0_child0.setHeight(100); - root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); - - const root_child0_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0_child0.setPositionType(PositionType.Static); - root_child0_child0_child0_child0_child0.setMargin(Edge.Left, 100); - root_child0_child0_child0_child0_child0.setWidth(100); - root_child0_child0_child0_child0_child0.setHeight(100); - root_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0, 0); - - const root_child0_child0_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0_child0_child0_child0.setPosition(Edge.Left, 50); - root_child0_child0_child0_child0_child0_child0.setPosition(Edge.Top, 50); - root_child0_child0_child0_child0_child0_child0.setWidth(50); - root_child0_child0_child0_child0_child0_child0.setHeight(50); - root_child0_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(-350); - expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(-50); - expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 100); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setMargin(Edge.Left, 100); + root_child0_child0_child0.setWidth(100); + root_child0_child0_child0.setHeight(100); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0_child0.setMargin(Edge.Left, 100); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(100); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0_child0_child0.setMargin(Edge.Left, 100); + root_child0_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0_child0.setHeight(100); + root_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0, 0); + + const root_child0_child0_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0_child0_child0_child0.setPosition(Edge.Left, 50); + root_child0_child0_child0_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0_child0_child0_child0.setWidth(50); + root_child0_child0_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(-350); + expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_absolute_child_width_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setWidth("50%"); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth("50%"); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_relative_child_width_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setWidth("50%"); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth("50%"); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_static_child_width_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Static); - root_child0_child0_child0.setWidth("50%"); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setWidth("50%"); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_absolute_child_height_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight("50%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight("50%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); }); test('static_position_relative_child_height_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight("50%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight("50%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_static_child_height_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Static); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight("50%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight("50%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_absolute_child_left_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Left, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_relative_child_left_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPosition(Edge.Left, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPosition(Edge.Left, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_static_child_left_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Static); - root_child0_child0_child0.setPosition(Edge.Left, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setPosition(Edge.Left, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_absolute_child_right_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Right, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Right, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_relative_child_right_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPosition(Edge.Right, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPosition(Edge.Right, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_static_child_right_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Static); - root_child0_child0_child0.setPosition(Edge.Right, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setPosition(Edge.Right, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_absolute_child_top_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Top, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Top, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_relative_child_top_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPosition(Edge.Top, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPosition(Edge.Top, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_static_child_top_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Static); - root_child0_child0_child0.setPosition(Edge.Top, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setPosition(Edge.Top, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_absolute_child_bottom_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Bottom, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_relative_child_bottom_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPosition(Edge.Bottom, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(-50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(-50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPosition(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_static_child_bottom_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Static); - root_child0_child0_child0.setPosition(Edge.Bottom, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setPosition(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_absolute_child_margin_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setMargin(Edge.Left, "50%"); - root_child0_child0_child0.setMargin(Edge.Top, "50%"); - root_child0_child0_child0.setMargin(Edge.Right, "50%"); - root_child0_child0_child0.setMargin(Edge.Bottom, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); - expect(root_child0_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, "50%"); + root_child0_child0_child0.setMargin(Edge.Top, "50%"); + root_child0_child0_child0.setMargin(Edge.Right, "50%"); + root_child0_child0_child0.setMargin(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_relative_child_margin_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setMargin(Edge.Left, "50%"); - root_child0_child0_child0.setMargin(Edge.Top, "50%"); - root_child0_child0_child0.setMargin(Edge.Right, "50%"); - root_child0_child0_child0.setMargin(Edge.Bottom, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setMargin(Edge.Left, "50%"); + root_child0_child0_child0.setMargin(Edge.Top, "50%"); + root_child0_child0_child0.setMargin(Edge.Right, "50%"); + root_child0_child0_child0.setMargin(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_static_child_margin_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Static); - root_child0_child0_child0.setMargin(Edge.Left, "50%"); - root_child0_child0_child0.setMargin(Edge.Top, "50%"); - root_child0_child0_child0.setMargin(Edge.Right, "50%"); - root_child0_child0_child0.setMargin(Edge.Bottom, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(50); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setMargin(Edge.Left, "50%"); + root_child0_child0_child0.setMargin(Edge.Top, "50%"); + root_child0_child0_child0.setMargin(Edge.Right, "50%"); + root_child0_child0_child0.setMargin(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_absolute_child_padding_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPadding(Edge.Left, "50%"); - root_child0_child0_child0.setPadding(Edge.Top, "50%"); - root_child0_child0_child0.setPadding(Edge.Right, "50%"); - root_child0_child0_child0.setPadding(Edge.Bottom, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0_child0.getComputedHeight()).toBe(200); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-100); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0_child0.getComputedHeight()).toBe(200); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPadding(Edge.Left, "50%"); + root_child0_child0_child0.setPadding(Edge.Top, "50%"); + root_child0_child0_child0.setPadding(Edge.Right, "50%"); + root_child0_child0_child0.setPadding(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-100); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(200); }); test('static_position_relative_child_padding_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPadding(Edge.Left, "50%"); - root_child0_child0_child0.setPadding(Edge.Top, "50%"); - root_child0_child0_child0.setPadding(Edge.Right, "50%"); - root_child0_child0_child0.setPadding(Edge.Bottom, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPadding(Edge.Left, "50%"); + root_child0_child0_child0.setPadding(Edge.Top, "50%"); + root_child0_child0_child0.setPadding(Edge.Right, "50%"); + root_child0_child0_child0.setPadding(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); }); test('static_position_static_child_padding_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Static); - root_child0_child0_child0.setPadding(Edge.Left, "50%"); - root_child0_child0_child0.setPadding(Edge.Top, "50%"); - root_child0_child0_child0.setPadding(Edge.Right, "50%"); - root_child0_child0_child0.setPadding(Edge.Bottom, "50%"); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setPadding(Edge.Left, "50%"); + root_child0_child0_child0.setPadding(Edge.Top, "50%"); + root_child0_child0_child0.setPadding(Edge.Right, "50%"); + root_child0_child0_child0.setPadding(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); }); test('static_position_absolute_child_border_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_relative_child_border_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_static_child_border_percentage', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setWidth(200); - root_child0.setHeight(200); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Static); - root_child0_child0_child0.setWidth(50); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(200); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(200); - expect(root_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_absolute_child_containing_block_padding_box', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 100); - root_child0.setPadding(Edge.Top, 100); - root_child0.setPadding(Edge.Right, 100); - root_child0.setPadding(Edge.Bottom, 100); - root_child0.setWidth(400); - root_child0.setHeight(400); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setWidth("50%"); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(200); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-100); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 100); + root_child0.setPadding(Edge.Top, 100); + root_child0.setPadding(Edge.Right, 100); + root_child0.setPadding(Edge.Bottom, 100); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth("50%"); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(200); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-100); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_relative_child_containing_block_padding_box', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 100); - root_child0.setPadding(Edge.Top, 100); - root_child0.setPadding(Edge.Right, 100); - root_child0.setPadding(Edge.Bottom, 100); - root_child0.setWidth(400); - root_child0.setHeight(400); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setWidth("50%"); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(200); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 100); + root_child0.setPadding(Edge.Top, 100); + root_child0.setPadding(Edge.Right, 100); + root_child0.setPadding(Edge.Bottom, 100); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth("50%"); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(200); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_static_child_containing_block_padding_box', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 100); - root_child0.setPadding(Edge.Top, 100); - root_child0.setPadding(Edge.Right, 100); - root_child0.setPadding(Edge.Bottom, 100); - root_child0.setWidth(400); - root_child0.setHeight(400); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Static); - root_child0_child0_child0.setWidth("50%"); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(200); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(50); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(50); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 100); + root_child0.setPadding(Edge.Top, 100); + root_child0.setPadding(Edge.Right, 100); + root_child0.setPadding(Edge.Bottom, 100); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setWidth("50%"); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(200); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_absolute_child_containing_block_content_box', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 100); - root_child0.setPadding(Edge.Top, 100); - root_child0.setPadding(Edge.Right, 100); - root_child0.setPadding(Edge.Bottom, 100); - root_child0.setWidth(400); - root_child0.setHeight(400); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0.setWidth("50%"); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 100); + root_child0.setPadding(Edge.Top, 100); + root_child0.setPadding(Edge.Right, 100); + root_child0.setPadding(Edge.Bottom, 100); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setWidth("50%"); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_relative_child_containing_block_content_box', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 100); - root_child0.setPadding(Edge.Top, 100); - root_child0.setPadding(Edge.Right, 100); - root_child0.setPadding(Edge.Bottom, 100); - root_child0.setWidth(400); - root_child0.setHeight(400); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setWidth("50%"); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(200); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 100); + root_child0.setPadding(Edge.Top, 100); + root_child0.setPadding(Edge.Right, 100); + root_child0.setPadding(Edge.Bottom, 100); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("50%"); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(200); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_static_child_containing_block_content_box', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 100); - root_child0.setPadding(Edge.Top, 100); - root_child0.setPadding(Edge.Right, 100); - root_child0.setPadding(Edge.Bottom, 100); - root_child0.setWidth(400); - root_child0.setHeight(400); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth("50%"); - root_child0_child0.setHeight(50); - root_child0.insertChild(root_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(200); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 100); + root_child0.setPadding(Edge.Top, 100); + root_child0.setPadding(Edge.Right, 100); + root_child0.setPadding(Edge.Bottom, 100); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth("50%"); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(200); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_containing_block_padding_and_border', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 9); - root_child0.setPadding(Edge.Top, 8); - root_child0.setPadding(Edge.Right, 1); - root_child0.setPadding(Edge.Bottom, 4); - root_child0.setBorder(Edge.Left, 2); - root_child0.setBorder(Edge.Top, 5); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 4); - root_child0.setWidth(400); - root_child0.setHeight(400); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setWidth("41%"); - root_child0_child0_child0.setHeight("61%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(11); - expect(root_child0_child0.getComputedTop()).toBe(13); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0_child0.getComputedHeight()).toBe(239); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(292); - expect(root_child0_child0.getComputedTop()).toBe(13); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-60); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(160); - expect(root_child0_child0_child0.getComputedHeight()).toBe(239); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 9); + root_child0.setPadding(Edge.Top, 8); + root_child0.setPadding(Edge.Right, 1); + root_child0.setPadding(Edge.Bottom, 4); + root_child0.setBorder(Edge.Left, 2); + root_child0.setBorder(Edge.Top, 5); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 4); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth("41%"); + root_child0_child0_child0.setHeight("61%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(11); + expect(root_child0_child0.getComputedTop()).toBe(13); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0_child0.getComputedHeight()).toBe(239); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(292); + expect(root_child0_child0.getComputedTop()).toBe(13); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-60); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0_child0.getComputedHeight()).toBe(239); }); test('static_position_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root_child0.setWidth(500); - root_child0.setHeight(500); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0_child0.setWidth(200); - root_child0_child0.setHeight(200); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Left, 2); - root_child0_child0_child0.setPosition(Edge.Right, 12); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0.setWidth("41%"); - root_child0_child0_child0.setHeight("63%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(513); - expect(root.getComputedHeight()).toBe(506); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(1); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0_child0.getComputedHeight()).toBe(306); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(513); - expect(root.getComputedHeight()).toBe(506); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(279); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-2); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0_child0.getComputedHeight()).toBe(306); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root_child0.setWidth(500); + root_child0.setHeight(500); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, 2); + root_child0_child0_child0.setPosition(Edge.Right, 12); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("41%"); + root_child0_child0_child0.setHeight("63%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(1); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(279); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-2); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); }); test('static_position_no_position_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root_child0.setWidth(500); - root_child0.setHeight(500); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0_child0.setWidth(200); - root_child0_child0.setHeight(200); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0.setWidth("41%"); - root_child0_child0_child0.setHeight("63%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(513); - expect(root.getComputedHeight()).toBe(506); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(18); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0_child0.getComputedHeight()).toBe(306); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(513); - expect(root.getComputedHeight()).toBe(506); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(279); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-15); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0_child0.getComputedHeight()).toBe(306); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root_child0.setWidth(500); + root_child0.setHeight(500); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("41%"); + root_child0_child0_child0.setHeight("63%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(279); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-15); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); }); test('static_position_zero_for_inset_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root_child0.setWidth(500); - root_child0.setHeight(500); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0_child0.setWidth(200); - root_child0_child0.setHeight(200); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Left, "0%"); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0.setWidth("41%"); - root_child0_child0_child0.setHeight("63%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(513); - expect(root.getComputedHeight()).toBe(506); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-1); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0_child0.getComputedHeight()).toBe(306); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(513); - expect(root.getComputedHeight()).toBe(506); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(279); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-265); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0_child0.getComputedHeight()).toBe(306); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root_child0.setWidth(500); + root_child0.setHeight(500); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, "0%"); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("41%"); + root_child0_child0_child0.setHeight("63%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-1); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(279); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-265); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); }); test('static_position_start_inset_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root_child0.setWidth(500); - root_child0.setHeight(500); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0_child0.setWidth(200); - root_child0_child0.setHeight(200); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Start, 12); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0.setWidth("41%"); - root_child0_child0_child0.setHeight("63%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(513); - expect(root.getComputedHeight()).toBe(506); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(11); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0_child0.getComputedHeight()).toBe(306); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(513); - expect(root.getComputedHeight()).toBe(506); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(279); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-2); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0_child0.getComputedHeight()).toBe(306); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root_child0.setWidth(500); + root_child0.setHeight(500); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Start, 12); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("41%"); + root_child0_child0_child0.setHeight("63%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(11); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(279); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-2); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); }); test('static_position_end_inset_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root_child0.setWidth(500); - root_child0.setHeight(500); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0_child0.setWidth(200); - root_child0_child0.setHeight(200); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.End, 4); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0.setWidth("41%"); - root_child0_child0_child0.setHeight("63%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(513); - expect(root.getComputedHeight()).toBe(506); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(270); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0_child0.getComputedHeight()).toBe(306); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(513); - expect(root.getComputedHeight()).toBe(506); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(500); - expect(root_child0.getComputedHeight()).toBe(500); - - expect(root_child0_child0.getComputedLeft()).toBe(279); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0.getComputedHeight()).toBe(200); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-261); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(200); - expect(root_child0_child0_child0.getComputedHeight()).toBe(306); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root_child0.setWidth(500); + root_child0.setHeight(500); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.End, 4); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("41%"); + root_child0_child0_child0.setHeight("63%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(270); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(279); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-261); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); }); test('static_position_row_reverse_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.RowReverse); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0.setHeight("12%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0_child0.setWidth(100); - root_child0_child0_child0_child0.setHeight(50); - root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(69); - expect(root.getComputedHeight()).toBe(79); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(56); - expect(root_child0.getComputedHeight()).toBe(73); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0.getComputedHeight()).toBe(22); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-128); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(133); - expect(root_child0_child0_child0.getComputedHeight()).toBe(23); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(69); - expect(root.getComputedHeight()).toBe(79); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(56); - expect(root_child0.getComputedHeight()).toBe(73); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0.getComputedHeight()).toBe(22); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(18); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(133); - expect(root_child0_child0_child0.getComputedHeight()).toBe(23); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setHeight("12%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-128); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(133); + expect(root_child0_child0_child0.getComputedHeight()).toBe(23); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(133); + expect(root_child0_child0_child0.getComputedHeight()).toBe(23); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_column_reverse_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexDirection(FlexDirection.ColumnReverse); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0.setWidth("21%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0_child0.setWidth(100); - root_child0_child0_child0_child0.setHeight(50); - root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(69); - expect(root.getComputedHeight()).toBe(79); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(56); - expect(root_child0.getComputedHeight()).toBe(73); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0.getComputedHeight()).toBe(22); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(18); - expect(root_child0_child0_child0.getComputedTop()).toBe(-82); - expect(root_child0_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(69); - expect(root.getComputedHeight()).toBe(79); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(56); - expect(root_child0.getComputedHeight()).toBe(73); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0.getComputedHeight()).toBe(22); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-15); - expect(root_child0_child0_child0.getComputedTop()).toBe(-82); - expect(root_child0_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(-82); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-15); + expect(root_child0_child0_child0.getComputedTop()).toBe(-82); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_justify_flex_start_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0.setWidth("21%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0_child0.setWidth(100); - root_child0_child0_child0_child0.setHeight(50); - root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); - - const root_child0_child0_child1 = Yoga.Node.create(config); - root_child0_child0_child1.setMargin(Edge.Left, 9); - root_child0_child0_child1.setMargin(Edge.Top, 12); - root_child0_child0_child1.setMargin(Edge.Right, 4); - root_child0_child0_child1.setMargin(Edge.Bottom, 7); - root_child0_child0_child1.setPadding(Edge.Left, 5); - root_child0_child0_child1.setPadding(Edge.Top, 3); - root_child0_child0_child1.setPadding(Edge.Right, 8); - root_child0_child0_child1.setPadding(Edge.Bottom, 10); - root_child0_child0_child1.setBorder(Edge.Left, 2); - root_child0_child0_child1.setBorder(Edge.Top, 1); - root_child0_child0_child1.setBorder(Edge.Right, 5); - root_child0_child0_child1.setBorder(Edge.Bottom, 9); - root_child0_child0_child1.setWidth("10%"); - root_child0_child0.insertChild(root_child0_child0_child1, 1); - - const root_child0_child0_child1_child0 = Yoga.Node.create(config); - root_child0_child0_child1_child0.setMargin(Edge.Left, 9); - root_child0_child0_child1_child0.setMargin(Edge.Top, 12); - root_child0_child0_child1_child0.setMargin(Edge.Right, 4); - root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child1_child0.setPadding(Edge.Left, 5); - root_child0_child0_child1_child0.setPadding(Edge.Top, 3); - root_child0_child0_child1_child0.setPadding(Edge.Right, 8); - root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child1_child0.setBorder(Edge.Left, 2); - root_child0_child0_child1_child0.setBorder(Edge.Top, 1); - root_child0_child0_child1_child0.setBorder(Edge.Right, 5); - root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child1_child0.setWidth(100); - root_child0_child0_child1_child0.setHeight(50); - root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); - - const root_child0_child0_child2 = Yoga.Node.create(config); - root_child0_child0_child2.setMargin(Edge.Left, 9); - root_child0_child0_child2.setMargin(Edge.Top, 12); - root_child0_child0_child2.setMargin(Edge.Right, 4); - root_child0_child0_child2.setMargin(Edge.Bottom, 7); - root_child0_child0_child2.setPadding(Edge.Left, 5); - root_child0_child0_child2.setPadding(Edge.Top, 3); - root_child0_child0_child2.setPadding(Edge.Right, 8); - root_child0_child0_child2.setPadding(Edge.Bottom, 10); - root_child0_child0_child2.setBorder(Edge.Left, 2); - root_child0_child0_child2.setBorder(Edge.Top, 1); - root_child0_child0_child2.setBorder(Edge.Right, 5); - root_child0_child0_child2.setBorder(Edge.Bottom, 9); - root_child0_child0_child2.setWidth("10%"); - root_child0_child0.insertChild(root_child0_child0_child2, 2); - - const root_child0_child0_child2_child0 = Yoga.Node.create(config); - root_child0_child0_child2_child0.setMargin(Edge.Left, 9); - root_child0_child0_child2_child0.setMargin(Edge.Top, 12); - root_child0_child0_child2_child0.setMargin(Edge.Right, 4); - root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child2_child0.setPadding(Edge.Left, 5); - root_child0_child0_child2_child0.setPadding(Edge.Top, 3); - root_child0_child0_child2_child0.setPadding(Edge.Right, 8); - root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child2_child0.setBorder(Edge.Left, 2); - root_child0_child0_child2_child0.setBorder(Edge.Top, 1); - root_child0_child0_child2_child0.setBorder(Edge.Right, 5); - root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child2_child0.setWidth(100); - root_child0_child0_child2_child0.setHeight(50); - root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(215); - expect(root.getComputedHeight()).toBe(301); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(202); - expect(root_child0.getComputedHeight()).toBe(295); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(166); - expect(root_child0_child0.getComputedHeight()).toBe(244); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(18); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(18); - expect(root_child0_child0_child1.getComputedTop()).toBe(29); - expect(root_child0_child0_child1.getComputedWidth()).toBe(20); - expect(root_child0_child0_child1.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(18); - expect(root_child0_child0_child2.getComputedTop()).toBe(140); - expect(root_child0_child0_child2.getComputedWidth()).toBe(20); - expect(root_child0_child0_child2.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(215); - expect(root.getComputedHeight()).toBe(301); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(202); - expect(root_child0.getComputedHeight()).toBe(295); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(166); - expect(root_child0_child0.getComputedHeight()).toBe(244); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(111); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(131); - expect(root_child0_child0_child1.getComputedTop()).toBe(29); - expect(root_child0_child0_child1.getComputedWidth()).toBe(20); - expect(root_child0_child0_child1.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(131); - expect(root_child0_child0_child2.getComputedTop()).toBe(140); - expect(root_child0_child0_child2.getComputedWidth()).toBe(20); - expect(root_child0_child0_child2.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setMargin(Edge.Left, 9); + root_child0_child0_child1.setMargin(Edge.Top, 12); + root_child0_child0_child1.setMargin(Edge.Right, 4); + root_child0_child0_child1.setMargin(Edge.Bottom, 7); + root_child0_child0_child1.setPadding(Edge.Left, 5); + root_child0_child0_child1.setPadding(Edge.Top, 3); + root_child0_child0_child1.setPadding(Edge.Right, 8); + root_child0_child0_child1.setPadding(Edge.Bottom, 10); + root_child0_child0_child1.setBorder(Edge.Left, 2); + root_child0_child0_child1.setBorder(Edge.Top, 1); + root_child0_child0_child1.setBorder(Edge.Right, 5); + root_child0_child0_child1.setBorder(Edge.Bottom, 9); + root_child0_child0_child1.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setMargin(Edge.Left, 9); + root_child0_child0_child1_child0.setMargin(Edge.Top, 12); + root_child0_child0_child1_child0.setMargin(Edge.Right, 4); + root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child1_child0.setPadding(Edge.Left, 5); + root_child0_child0_child1_child0.setPadding(Edge.Top, 3); + root_child0_child0_child1_child0.setPadding(Edge.Right, 8); + root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child1_child0.setBorder(Edge.Left, 2); + root_child0_child0_child1_child0.setBorder(Edge.Top, 1); + root_child0_child0_child1_child0.setBorder(Edge.Right, 5); + root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child1_child0.setWidth(100); + root_child0_child0_child1_child0.setHeight(50); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setMargin(Edge.Left, 9); + root_child0_child0_child2.setMargin(Edge.Top, 12); + root_child0_child0_child2.setMargin(Edge.Right, 4); + root_child0_child0_child2.setMargin(Edge.Bottom, 7); + root_child0_child0_child2.setPadding(Edge.Left, 5); + root_child0_child0_child2.setPadding(Edge.Top, 3); + root_child0_child0_child2.setPadding(Edge.Right, 8); + root_child0_child0_child2.setPadding(Edge.Bottom, 10); + root_child0_child0_child2.setBorder(Edge.Left, 2); + root_child0_child0_child2.setBorder(Edge.Top, 1); + root_child0_child0_child2.setBorder(Edge.Right, 5); + root_child0_child0_child2.setBorder(Edge.Bottom, 9); + root_child0_child0_child2.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setMargin(Edge.Left, 9); + root_child0_child0_child2_child0.setMargin(Edge.Top, 12); + root_child0_child0_child2_child0.setMargin(Edge.Right, 4); + root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child2_child0.setPadding(Edge.Left, 5); + root_child0_child0_child2_child0.setPadding(Edge.Top, 3); + root_child0_child0_child2_child0.setPadding(Edge.Right, 8); + root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child2_child0.setBorder(Edge.Left, 2); + root_child0_child0_child2_child0.setBorder(Edge.Top, 1); + root_child0_child0_child2_child0.setBorder(Edge.Right, 5); + root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child2_child0.setWidth(100); + root_child0_child0_child2_child0.setHeight(50); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(18); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(18); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(111); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(131); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(131); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); }); test('static_position_justify_flex_start_position_set_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Right, 30); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0.setWidth("21%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0_child0.setWidth(100); - root_child0_child0_child0_child0.setHeight(50); - root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); - - const root_child0_child0_child1 = Yoga.Node.create(config); - root_child0_child0_child1.setMargin(Edge.Left, 9); - root_child0_child0_child1.setMargin(Edge.Top, 12); - root_child0_child0_child1.setMargin(Edge.Right, 4); - root_child0_child0_child1.setMargin(Edge.Bottom, 7); - root_child0_child0_child1.setPadding(Edge.Left, 5); - root_child0_child0_child1.setPadding(Edge.Top, 3); - root_child0_child0_child1.setPadding(Edge.Right, 8); - root_child0_child0_child1.setPadding(Edge.Bottom, 10); - root_child0_child0_child1.setBorder(Edge.Left, 2); - root_child0_child0_child1.setBorder(Edge.Top, 1); - root_child0_child0_child1.setBorder(Edge.Right, 5); - root_child0_child0_child1.setBorder(Edge.Bottom, 9); - root_child0_child0_child1.setWidth("10%"); - root_child0_child0.insertChild(root_child0_child0_child1, 1); - - const root_child0_child0_child1_child0 = Yoga.Node.create(config); - root_child0_child0_child1_child0.setMargin(Edge.Left, 9); - root_child0_child0_child1_child0.setMargin(Edge.Top, 12); - root_child0_child0_child1_child0.setMargin(Edge.Right, 4); - root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child1_child0.setPadding(Edge.Left, 5); - root_child0_child0_child1_child0.setPadding(Edge.Top, 3); - root_child0_child0_child1_child0.setPadding(Edge.Right, 8); - root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child1_child0.setBorder(Edge.Left, 2); - root_child0_child0_child1_child0.setBorder(Edge.Top, 1); - root_child0_child0_child1_child0.setBorder(Edge.Right, 5); - root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child1_child0.setWidth(100); - root_child0_child0_child1_child0.setHeight(50); - root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); - - const root_child0_child0_child2 = Yoga.Node.create(config); - root_child0_child0_child2.setMargin(Edge.Left, 9); - root_child0_child0_child2.setMargin(Edge.Top, 12); - root_child0_child0_child2.setMargin(Edge.Right, 4); - root_child0_child0_child2.setMargin(Edge.Bottom, 7); - root_child0_child0_child2.setPadding(Edge.Left, 5); - root_child0_child0_child2.setPadding(Edge.Top, 3); - root_child0_child0_child2.setPadding(Edge.Right, 8); - root_child0_child0_child2.setPadding(Edge.Bottom, 10); - root_child0_child0_child2.setBorder(Edge.Left, 2); - root_child0_child0_child2.setBorder(Edge.Top, 1); - root_child0_child0_child2.setBorder(Edge.Right, 5); - root_child0_child0_child2.setBorder(Edge.Bottom, 9); - root_child0_child0_child2.setWidth("10%"); - root_child0_child0.insertChild(root_child0_child0_child2, 2); - - const root_child0_child0_child2_child0 = Yoga.Node.create(config); - root_child0_child0_child2_child0.setMargin(Edge.Left, 9); - root_child0_child0_child2_child0.setMargin(Edge.Top, 12); - root_child0_child0_child2_child0.setMargin(Edge.Right, 4); - root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child2_child0.setPadding(Edge.Left, 5); - root_child0_child0_child2_child0.setPadding(Edge.Top, 3); - root_child0_child0_child2_child0.setPadding(Edge.Right, 8); - root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child2_child0.setBorder(Edge.Left, 2); - root_child0_child0_child2_child0.setBorder(Edge.Top, 1); - root_child0_child0_child2_child0.setBorder(Edge.Right, 5); - root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child2_child0.setWidth(100); - root_child0_child0_child2_child0.setHeight(50); - root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(215); - expect(root.getComputedHeight()).toBe(301); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(202); - expect(root_child0.getComputedHeight()).toBe(295); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(166); - expect(root_child0_child0.getComputedHeight()).toBe(244); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(106); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(18); - expect(root_child0_child0_child1.getComputedTop()).toBe(29); - expect(root_child0_child0_child1.getComputedWidth()).toBe(20); - expect(root_child0_child0_child1.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(18); - expect(root_child0_child0_child2.getComputedTop()).toBe(140); - expect(root_child0_child0_child2.getComputedWidth()).toBe(20); - expect(root_child0_child0_child2.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(215); - expect(root.getComputedHeight()).toBe(301); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(202); - expect(root_child0.getComputedHeight()).toBe(295); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(166); - expect(root_child0_child0.getComputedHeight()).toBe(244); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(106); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(131); - expect(root_child0_child0_child1.getComputedTop()).toBe(29); - expect(root_child0_child0_child1.getComputedWidth()).toBe(20); - expect(root_child0_child0_child1.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(131); - expect(root_child0_child0_child2.getComputedTop()).toBe(140); - expect(root_child0_child0_child2.getComputedWidth()).toBe(20); - expect(root_child0_child0_child2.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Right, 30); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setMargin(Edge.Left, 9); + root_child0_child0_child1.setMargin(Edge.Top, 12); + root_child0_child0_child1.setMargin(Edge.Right, 4); + root_child0_child0_child1.setMargin(Edge.Bottom, 7); + root_child0_child0_child1.setPadding(Edge.Left, 5); + root_child0_child0_child1.setPadding(Edge.Top, 3); + root_child0_child0_child1.setPadding(Edge.Right, 8); + root_child0_child0_child1.setPadding(Edge.Bottom, 10); + root_child0_child0_child1.setBorder(Edge.Left, 2); + root_child0_child0_child1.setBorder(Edge.Top, 1); + root_child0_child0_child1.setBorder(Edge.Right, 5); + root_child0_child0_child1.setBorder(Edge.Bottom, 9); + root_child0_child0_child1.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setMargin(Edge.Left, 9); + root_child0_child0_child1_child0.setMargin(Edge.Top, 12); + root_child0_child0_child1_child0.setMargin(Edge.Right, 4); + root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child1_child0.setPadding(Edge.Left, 5); + root_child0_child0_child1_child0.setPadding(Edge.Top, 3); + root_child0_child0_child1_child0.setPadding(Edge.Right, 8); + root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child1_child0.setBorder(Edge.Left, 2); + root_child0_child0_child1_child0.setBorder(Edge.Top, 1); + root_child0_child0_child1_child0.setBorder(Edge.Right, 5); + root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child1_child0.setWidth(100); + root_child0_child0_child1_child0.setHeight(50); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setMargin(Edge.Left, 9); + root_child0_child0_child2.setMargin(Edge.Top, 12); + root_child0_child0_child2.setMargin(Edge.Right, 4); + root_child0_child0_child2.setMargin(Edge.Bottom, 7); + root_child0_child0_child2.setPadding(Edge.Left, 5); + root_child0_child0_child2.setPadding(Edge.Top, 3); + root_child0_child0_child2.setPadding(Edge.Right, 8); + root_child0_child0_child2.setPadding(Edge.Bottom, 10); + root_child0_child0_child2.setBorder(Edge.Left, 2); + root_child0_child0_child2.setBorder(Edge.Top, 1); + root_child0_child0_child2.setBorder(Edge.Right, 5); + root_child0_child0_child2.setBorder(Edge.Bottom, 9); + root_child0_child0_child2.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setMargin(Edge.Left, 9); + root_child0_child0_child2_child0.setMargin(Edge.Top, 12); + root_child0_child0_child2_child0.setMargin(Edge.Right, 4); + root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child2_child0.setPadding(Edge.Left, 5); + root_child0_child0_child2_child0.setPadding(Edge.Top, 3); + root_child0_child0_child2_child0.setPadding(Edge.Right, 8); + root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child2_child0.setBorder(Edge.Left, 2); + root_child0_child0_child2_child0.setBorder(Edge.Top, 1); + root_child0_child0_child2_child0.setBorder(Edge.Right, 5); + root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child2_child0.setWidth(100); + root_child0_child0_child2_child0.setHeight(50); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(106); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(18); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(18); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(106); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(131); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(131); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); }); test('static_position_no_definite_size_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Left, "23%"); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0_child0.setWidth(100); - root_child0_child0_child0_child0.setHeight(50); - root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(69); - expect(root.getComputedHeight()).toBe(79); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(56); - expect(root_child0.getComputedHeight()).toBe(73); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0.getComputedHeight()).toBe(22); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(9); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(133); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(69); - expect(root.getComputedHeight()).toBe(79); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(56); - expect(root_child0.getComputedHeight()).toBe(73); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0.getComputedHeight()).toBe(22); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(9); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(133); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, "23%"); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(133); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(133); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_both_insets_set_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setPosition(Edge.Left, "23%"); - root_child0_child0_child0.setPosition(Edge.Right, 13); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0_child0.setWidth(100); - root_child0_child0_child0_child0.setHeight(50); - root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(69); - expect(root.getComputedHeight()).toBe(79); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(56); - expect(root_child0.getComputedHeight()).toBe(73); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0.getComputedHeight()).toBe(22); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(9); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(69); - expect(root.getComputedHeight()).toBe(79); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(56); - expect(root_child0.getComputedHeight()).toBe(73); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0.getComputedHeight()).toBe(22); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(-3); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(20); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, "23%"); + root_child0_child0_child0.setPosition(Edge.Right, 13); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-3); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); }); test('static_position_justify_center_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setJustifyContent(Justify.Center); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0.setWidth("21%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0_child0.setWidth(100); - root_child0_child0_child0_child0.setHeight(50); - root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); - - const root_child0_child0_child1 = Yoga.Node.create(config); - root_child0_child0_child1.setMargin(Edge.Left, 9); - root_child0_child0_child1.setMargin(Edge.Top, 12); - root_child0_child0_child1.setMargin(Edge.Right, 4); - root_child0_child0_child1.setMargin(Edge.Bottom, 7); - root_child0_child0_child1.setPadding(Edge.Left, 5); - root_child0_child0_child1.setPadding(Edge.Top, 3); - root_child0_child0_child1.setPadding(Edge.Right, 8); - root_child0_child0_child1.setPadding(Edge.Bottom, 10); - root_child0_child0_child1.setBorder(Edge.Left, 2); - root_child0_child0_child1.setBorder(Edge.Top, 1); - root_child0_child0_child1.setBorder(Edge.Right, 5); - root_child0_child0_child1.setBorder(Edge.Bottom, 9); - root_child0_child0_child1.setWidth("10%"); - root_child0_child0.insertChild(root_child0_child0_child1, 1); - - const root_child0_child0_child1_child0 = Yoga.Node.create(config); - root_child0_child0_child1_child0.setMargin(Edge.Left, 9); - root_child0_child0_child1_child0.setMargin(Edge.Top, 12); - root_child0_child0_child1_child0.setMargin(Edge.Right, 4); - root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child1_child0.setPadding(Edge.Left, 5); - root_child0_child0_child1_child0.setPadding(Edge.Top, 3); - root_child0_child0_child1_child0.setPadding(Edge.Right, 8); - root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child1_child0.setBorder(Edge.Left, 2); - root_child0_child0_child1_child0.setBorder(Edge.Top, 1); - root_child0_child0_child1_child0.setBorder(Edge.Right, 5); - root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child1_child0.setWidth(100); - root_child0_child0_child1_child0.setHeight(50); - root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); - - const root_child0_child0_child2 = Yoga.Node.create(config); - root_child0_child0_child2.setMargin(Edge.Left, 9); - root_child0_child0_child2.setMargin(Edge.Top, 12); - root_child0_child0_child2.setMargin(Edge.Right, 4); - root_child0_child0_child2.setMargin(Edge.Bottom, 7); - root_child0_child0_child2.setPadding(Edge.Left, 5); - root_child0_child0_child2.setPadding(Edge.Top, 3); - root_child0_child0_child2.setPadding(Edge.Right, 8); - root_child0_child0_child2.setPadding(Edge.Bottom, 10); - root_child0_child0_child2.setBorder(Edge.Left, 2); - root_child0_child0_child2.setBorder(Edge.Top, 1); - root_child0_child0_child2.setBorder(Edge.Right, 5); - root_child0_child0_child2.setBorder(Edge.Bottom, 9); - root_child0_child0_child2.setWidth("10%"); - root_child0_child0.insertChild(root_child0_child0_child2, 2); - - const root_child0_child0_child2_child0 = Yoga.Node.create(config); - root_child0_child0_child2_child0.setMargin(Edge.Left, 9); - root_child0_child0_child2_child0.setMargin(Edge.Top, 12); - root_child0_child0_child2_child0.setMargin(Edge.Right, 4); - root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child2_child0.setPadding(Edge.Left, 5); - root_child0_child0_child2_child0.setPadding(Edge.Top, 3); - root_child0_child0_child2_child0.setPadding(Edge.Right, 8); - root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child2_child0.setBorder(Edge.Left, 2); - root_child0_child0_child2_child0.setBorder(Edge.Top, 1); - root_child0_child0_child2_child0.setBorder(Edge.Right, 5); - root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child2_child0.setWidth(100); - root_child0_child0_child2_child0.setHeight(50); - root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(215); - expect(root.getComputedHeight()).toBe(301); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(202); - expect(root_child0.getComputedHeight()).toBe(295); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(166); - expect(root_child0_child0.getComputedHeight()).toBe(244); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(18); - expect(root_child0_child0_child0.getComputedTop()).toBe(85); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(18); - expect(root_child0_child0_child1.getComputedTop()).toBe(29); - expect(root_child0_child0_child1.getComputedWidth()).toBe(20); - expect(root_child0_child0_child1.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(18); - expect(root_child0_child0_child2.getComputedTop()).toBe(140); - expect(root_child0_child0_child2.getComputedWidth()).toBe(20); - expect(root_child0_child0_child2.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(215); - expect(root.getComputedHeight()).toBe(301); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(202); - expect(root_child0.getComputedHeight()).toBe(295); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(166); - expect(root_child0_child0.getComputedHeight()).toBe(244); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(111); - expect(root_child0_child0_child0.getComputedTop()).toBe(85); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(131); - expect(root_child0_child0_child1.getComputedTop()).toBe(29); - expect(root_child0_child0_child1.getComputedWidth()).toBe(20); - expect(root_child0_child0_child1.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(131); - expect(root_child0_child0_child2.getComputedTop()).toBe(140); - expect(root_child0_child0_child2.getComputedWidth()).toBe(20); - expect(root_child0_child0_child2.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setJustifyContent(Justify.Center); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setMargin(Edge.Left, 9); + root_child0_child0_child1.setMargin(Edge.Top, 12); + root_child0_child0_child1.setMargin(Edge.Right, 4); + root_child0_child0_child1.setMargin(Edge.Bottom, 7); + root_child0_child0_child1.setPadding(Edge.Left, 5); + root_child0_child0_child1.setPadding(Edge.Top, 3); + root_child0_child0_child1.setPadding(Edge.Right, 8); + root_child0_child0_child1.setPadding(Edge.Bottom, 10); + root_child0_child0_child1.setBorder(Edge.Left, 2); + root_child0_child0_child1.setBorder(Edge.Top, 1); + root_child0_child0_child1.setBorder(Edge.Right, 5); + root_child0_child0_child1.setBorder(Edge.Bottom, 9); + root_child0_child0_child1.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setMargin(Edge.Left, 9); + root_child0_child0_child1_child0.setMargin(Edge.Top, 12); + root_child0_child0_child1_child0.setMargin(Edge.Right, 4); + root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child1_child0.setPadding(Edge.Left, 5); + root_child0_child0_child1_child0.setPadding(Edge.Top, 3); + root_child0_child0_child1_child0.setPadding(Edge.Right, 8); + root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child1_child0.setBorder(Edge.Left, 2); + root_child0_child0_child1_child0.setBorder(Edge.Top, 1); + root_child0_child0_child1_child0.setBorder(Edge.Right, 5); + root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child1_child0.setWidth(100); + root_child0_child0_child1_child0.setHeight(50); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setMargin(Edge.Left, 9); + root_child0_child0_child2.setMargin(Edge.Top, 12); + root_child0_child0_child2.setMargin(Edge.Right, 4); + root_child0_child0_child2.setMargin(Edge.Bottom, 7); + root_child0_child0_child2.setPadding(Edge.Left, 5); + root_child0_child0_child2.setPadding(Edge.Top, 3); + root_child0_child0_child2.setPadding(Edge.Right, 8); + root_child0_child0_child2.setPadding(Edge.Bottom, 10); + root_child0_child0_child2.setBorder(Edge.Left, 2); + root_child0_child0_child2.setBorder(Edge.Top, 1); + root_child0_child0_child2.setBorder(Edge.Right, 5); + root_child0_child0_child2.setBorder(Edge.Bottom, 9); + root_child0_child0_child2.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setMargin(Edge.Left, 9); + root_child0_child0_child2_child0.setMargin(Edge.Top, 12); + root_child0_child0_child2_child0.setMargin(Edge.Right, 4); + root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child2_child0.setPadding(Edge.Left, 5); + root_child0_child0_child2_child0.setPadding(Edge.Top, 3); + root_child0_child0_child2_child0.setPadding(Edge.Right, 8); + root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child2_child0.setBorder(Edge.Left, 2); + root_child0_child0_child2_child0.setBorder(Edge.Top, 1); + root_child0_child0_child2_child0.setBorder(Edge.Right, 5); + root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child2_child0.setWidth(100); + root_child0_child0_child2_child0.setHeight(50); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(85); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(18); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(18); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(111); + expect(root_child0_child0_child0.getComputedTop()).toBe(85); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(131); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(131); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); }); test('static_position_justify_flex_end_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setJustifyContent(Justify.FlexEnd); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0.setWidth("21%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0_child0.setWidth(100); - root_child0_child0_child0_child0.setHeight(50); - root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); - - const root_child0_child0_child1 = Yoga.Node.create(config); - root_child0_child0_child1.setMargin(Edge.Left, 9); - root_child0_child0_child1.setMargin(Edge.Top, 12); - root_child0_child0_child1.setMargin(Edge.Right, 4); - root_child0_child0_child1.setMargin(Edge.Bottom, 7); - root_child0_child0_child1.setPadding(Edge.Left, 5); - root_child0_child0_child1.setPadding(Edge.Top, 3); - root_child0_child0_child1.setPadding(Edge.Right, 8); - root_child0_child0_child1.setPadding(Edge.Bottom, 10); - root_child0_child0_child1.setBorder(Edge.Left, 2); - root_child0_child0_child1.setBorder(Edge.Top, 1); - root_child0_child0_child1.setBorder(Edge.Right, 5); - root_child0_child0_child1.setBorder(Edge.Bottom, 9); - root_child0_child0_child1.setWidth("10%"); - root_child0_child0.insertChild(root_child0_child0_child1, 1); - - const root_child0_child0_child1_child0 = Yoga.Node.create(config); - root_child0_child0_child1_child0.setMargin(Edge.Left, 9); - root_child0_child0_child1_child0.setMargin(Edge.Top, 12); - root_child0_child0_child1_child0.setMargin(Edge.Right, 4); - root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child1_child0.setPadding(Edge.Left, 5); - root_child0_child0_child1_child0.setPadding(Edge.Top, 3); - root_child0_child0_child1_child0.setPadding(Edge.Right, 8); - root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child1_child0.setBorder(Edge.Left, 2); - root_child0_child0_child1_child0.setBorder(Edge.Top, 1); - root_child0_child0_child1_child0.setBorder(Edge.Right, 5); - root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child1_child0.setWidth(100); - root_child0_child0_child1_child0.setHeight(50); - root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); - - const root_child0_child0_child2 = Yoga.Node.create(config); - root_child0_child0_child2.setMargin(Edge.Left, 9); - root_child0_child0_child2.setMargin(Edge.Top, 12); - root_child0_child0_child2.setMargin(Edge.Right, 4); - root_child0_child0_child2.setMargin(Edge.Bottom, 7); - root_child0_child0_child2.setPadding(Edge.Left, 5); - root_child0_child0_child2.setPadding(Edge.Top, 3); - root_child0_child0_child2.setPadding(Edge.Right, 8); - root_child0_child0_child2.setPadding(Edge.Bottom, 10); - root_child0_child0_child2.setBorder(Edge.Left, 2); - root_child0_child0_child2.setBorder(Edge.Top, 1); - root_child0_child0_child2.setBorder(Edge.Right, 5); - root_child0_child0_child2.setBorder(Edge.Bottom, 9); - root_child0_child0_child2.setWidth("10%"); - root_child0_child0.insertChild(root_child0_child0_child2, 2); - - const root_child0_child0_child2_child0 = Yoga.Node.create(config); - root_child0_child0_child2_child0.setMargin(Edge.Left, 9); - root_child0_child0_child2_child0.setMargin(Edge.Top, 12); - root_child0_child0_child2_child0.setMargin(Edge.Right, 4); - root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child2_child0.setPadding(Edge.Left, 5); - root_child0_child0_child2_child0.setPadding(Edge.Top, 3); - root_child0_child0_child2_child0.setPadding(Edge.Right, 8); - root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child2_child0.setBorder(Edge.Left, 2); - root_child0_child0_child2_child0.setBorder(Edge.Top, 1); - root_child0_child0_child2_child0.setBorder(Edge.Right, 5); - root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child2_child0.setWidth(100); - root_child0_child0_child2_child0.setHeight(50); - root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(215); - expect(root.getComputedHeight()).toBe(301); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(202); - expect(root_child0.getComputedHeight()).toBe(295); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(166); - expect(root_child0_child0.getComputedHeight()).toBe(244); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(18); - expect(root_child0_child0_child0.getComputedTop()).toBe(140); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(18); - expect(root_child0_child0_child1.getComputedTop()).toBe(29); - expect(root_child0_child0_child1.getComputedWidth()).toBe(20); - expect(root_child0_child0_child1.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(18); - expect(root_child0_child0_child2.getComputedTop()).toBe(140); - expect(root_child0_child0_child2.getComputedWidth()).toBe(20); - expect(root_child0_child0_child2.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(215); - expect(root.getComputedHeight()).toBe(301); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(202); - expect(root_child0.getComputedHeight()).toBe(295); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(166); - expect(root_child0_child0.getComputedHeight()).toBe(244); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(111); - expect(root_child0_child0_child0.getComputedTop()).toBe(140); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(131); - expect(root_child0_child0_child1.getComputedTop()).toBe(29); - expect(root_child0_child0_child1.getComputedWidth()).toBe(20); - expect(root_child0_child0_child1.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(131); - expect(root_child0_child0_child2.getComputedTop()).toBe(140); - expect(root_child0_child0_child2.getComputedWidth()).toBe(20); - expect(root_child0_child0_child2.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setJustifyContent(Justify.FlexEnd); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setMargin(Edge.Left, 9); + root_child0_child0_child1.setMargin(Edge.Top, 12); + root_child0_child0_child1.setMargin(Edge.Right, 4); + root_child0_child0_child1.setMargin(Edge.Bottom, 7); + root_child0_child0_child1.setPadding(Edge.Left, 5); + root_child0_child0_child1.setPadding(Edge.Top, 3); + root_child0_child0_child1.setPadding(Edge.Right, 8); + root_child0_child0_child1.setPadding(Edge.Bottom, 10); + root_child0_child0_child1.setBorder(Edge.Left, 2); + root_child0_child0_child1.setBorder(Edge.Top, 1); + root_child0_child0_child1.setBorder(Edge.Right, 5); + root_child0_child0_child1.setBorder(Edge.Bottom, 9); + root_child0_child0_child1.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setMargin(Edge.Left, 9); + root_child0_child0_child1_child0.setMargin(Edge.Top, 12); + root_child0_child0_child1_child0.setMargin(Edge.Right, 4); + root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child1_child0.setPadding(Edge.Left, 5); + root_child0_child0_child1_child0.setPadding(Edge.Top, 3); + root_child0_child0_child1_child0.setPadding(Edge.Right, 8); + root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child1_child0.setBorder(Edge.Left, 2); + root_child0_child0_child1_child0.setBorder(Edge.Top, 1); + root_child0_child0_child1_child0.setBorder(Edge.Right, 5); + root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child1_child0.setWidth(100); + root_child0_child0_child1_child0.setHeight(50); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setMargin(Edge.Left, 9); + root_child0_child0_child2.setMargin(Edge.Top, 12); + root_child0_child0_child2.setMargin(Edge.Right, 4); + root_child0_child0_child2.setMargin(Edge.Bottom, 7); + root_child0_child0_child2.setPadding(Edge.Left, 5); + root_child0_child0_child2.setPadding(Edge.Top, 3); + root_child0_child0_child2.setPadding(Edge.Right, 8); + root_child0_child0_child2.setPadding(Edge.Bottom, 10); + root_child0_child0_child2.setBorder(Edge.Left, 2); + root_child0_child0_child2.setBorder(Edge.Top, 1); + root_child0_child0_child2.setBorder(Edge.Right, 5); + root_child0_child0_child2.setBorder(Edge.Bottom, 9); + root_child0_child0_child2.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setMargin(Edge.Left, 9); + root_child0_child0_child2_child0.setMargin(Edge.Top, 12); + root_child0_child0_child2_child0.setMargin(Edge.Right, 4); + root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child2_child0.setPadding(Edge.Left, 5); + root_child0_child0_child2_child0.setPadding(Edge.Top, 3); + root_child0_child0_child2_child0.setPadding(Edge.Right, 8); + root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child2_child0.setBorder(Edge.Left, 2); + root_child0_child0_child2_child0.setBorder(Edge.Top, 1); + root_child0_child0_child2_child0.setBorder(Edge.Right, 5); + root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child2_child0.setWidth(100); + root_child0_child0_child2_child0.setHeight(50); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(140); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(18); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(18); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(111); + expect(root_child0_child0_child0.getComputedTop()).toBe(140); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(131); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(131); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); }); test('static_position_align_flex_start_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setAlignItems(Align.FlexStart); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0.setWidth("21%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0_child0.setWidth(100); - root_child0_child0_child0_child0.setHeight(50); - root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); - - const root_child0_child0_child1 = Yoga.Node.create(config); - root_child0_child0_child1.setMargin(Edge.Left, 9); - root_child0_child0_child1.setMargin(Edge.Top, 12); - root_child0_child0_child1.setMargin(Edge.Right, 4); - root_child0_child0_child1.setMargin(Edge.Bottom, 7); - root_child0_child0_child1.setPadding(Edge.Left, 5); - root_child0_child0_child1.setPadding(Edge.Top, 3); - root_child0_child0_child1.setPadding(Edge.Right, 8); - root_child0_child0_child1.setPadding(Edge.Bottom, 10); - root_child0_child0_child1.setBorder(Edge.Left, 2); - root_child0_child0_child1.setBorder(Edge.Top, 1); - root_child0_child0_child1.setBorder(Edge.Right, 5); - root_child0_child0_child1.setBorder(Edge.Bottom, 9); - root_child0_child0_child1.setWidth("10%"); - root_child0_child0.insertChild(root_child0_child0_child1, 1); - - const root_child0_child0_child1_child0 = Yoga.Node.create(config); - root_child0_child0_child1_child0.setMargin(Edge.Left, 9); - root_child0_child0_child1_child0.setMargin(Edge.Top, 12); - root_child0_child0_child1_child0.setMargin(Edge.Right, 4); - root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child1_child0.setPadding(Edge.Left, 5); - root_child0_child0_child1_child0.setPadding(Edge.Top, 3); - root_child0_child0_child1_child0.setPadding(Edge.Right, 8); - root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child1_child0.setBorder(Edge.Left, 2); - root_child0_child0_child1_child0.setBorder(Edge.Top, 1); - root_child0_child0_child1_child0.setBorder(Edge.Right, 5); - root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child1_child0.setWidth(100); - root_child0_child0_child1_child0.setHeight(50); - root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); - - const root_child0_child0_child2 = Yoga.Node.create(config); - root_child0_child0_child2.setMargin(Edge.Left, 9); - root_child0_child0_child2.setMargin(Edge.Top, 12); - root_child0_child0_child2.setMargin(Edge.Right, 4); - root_child0_child0_child2.setMargin(Edge.Bottom, 7); - root_child0_child0_child2.setPadding(Edge.Left, 5); - root_child0_child0_child2.setPadding(Edge.Top, 3); - root_child0_child0_child2.setPadding(Edge.Right, 8); - root_child0_child0_child2.setPadding(Edge.Bottom, 10); - root_child0_child0_child2.setBorder(Edge.Left, 2); - root_child0_child0_child2.setBorder(Edge.Top, 1); - root_child0_child0_child2.setBorder(Edge.Right, 5); - root_child0_child0_child2.setBorder(Edge.Bottom, 9); - root_child0_child0_child2.setWidth("10%"); - root_child0_child0.insertChild(root_child0_child0_child2, 2); - - const root_child0_child0_child2_child0 = Yoga.Node.create(config); - root_child0_child0_child2_child0.setMargin(Edge.Left, 9); - root_child0_child0_child2_child0.setMargin(Edge.Top, 12); - root_child0_child0_child2_child0.setMargin(Edge.Right, 4); - root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child2_child0.setPadding(Edge.Left, 5); - root_child0_child0_child2_child0.setPadding(Edge.Top, 3); - root_child0_child0_child2_child0.setPadding(Edge.Right, 8); - root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child2_child0.setBorder(Edge.Left, 2); - root_child0_child0_child2_child0.setBorder(Edge.Top, 1); - root_child0_child0_child2_child0.setBorder(Edge.Right, 5); - root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child2_child0.setWidth(100); - root_child0_child0_child2_child0.setHeight(50); - root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(215); - expect(root.getComputedHeight()).toBe(301); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(202); - expect(root_child0.getComputedHeight()).toBe(295); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(166); - expect(root_child0_child0.getComputedHeight()).toBe(244); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(18); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(18); - expect(root_child0_child0_child1.getComputedTop()).toBe(29); - expect(root_child0_child0_child1.getComputedWidth()).toBe(20); - expect(root_child0_child0_child1.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(18); - expect(root_child0_child0_child2.getComputedTop()).toBe(140); - expect(root_child0_child0_child2.getComputedWidth()).toBe(20); - expect(root_child0_child0_child2.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(215); - expect(root.getComputedHeight()).toBe(301); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(202); - expect(root_child0.getComputedHeight()).toBe(295); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(166); - expect(root_child0_child0.getComputedHeight()).toBe(244); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(111); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(131); - expect(root_child0_child0_child1.getComputedTop()).toBe(29); - expect(root_child0_child0_child1.getComputedWidth()).toBe(20); - expect(root_child0_child0_child1.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(131); - expect(root_child0_child0_child2.getComputedTop()).toBe(140); - expect(root_child0_child0_child2.getComputedWidth()).toBe(20); - expect(root_child0_child0_child2.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setAlignItems(Align.FlexStart); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setMargin(Edge.Left, 9); + root_child0_child0_child1.setMargin(Edge.Top, 12); + root_child0_child0_child1.setMargin(Edge.Right, 4); + root_child0_child0_child1.setMargin(Edge.Bottom, 7); + root_child0_child0_child1.setPadding(Edge.Left, 5); + root_child0_child0_child1.setPadding(Edge.Top, 3); + root_child0_child0_child1.setPadding(Edge.Right, 8); + root_child0_child0_child1.setPadding(Edge.Bottom, 10); + root_child0_child0_child1.setBorder(Edge.Left, 2); + root_child0_child0_child1.setBorder(Edge.Top, 1); + root_child0_child0_child1.setBorder(Edge.Right, 5); + root_child0_child0_child1.setBorder(Edge.Bottom, 9); + root_child0_child0_child1.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setMargin(Edge.Left, 9); + root_child0_child0_child1_child0.setMargin(Edge.Top, 12); + root_child0_child0_child1_child0.setMargin(Edge.Right, 4); + root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child1_child0.setPadding(Edge.Left, 5); + root_child0_child0_child1_child0.setPadding(Edge.Top, 3); + root_child0_child0_child1_child0.setPadding(Edge.Right, 8); + root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child1_child0.setBorder(Edge.Left, 2); + root_child0_child0_child1_child0.setBorder(Edge.Top, 1); + root_child0_child0_child1_child0.setBorder(Edge.Right, 5); + root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child1_child0.setWidth(100); + root_child0_child0_child1_child0.setHeight(50); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setMargin(Edge.Left, 9); + root_child0_child0_child2.setMargin(Edge.Top, 12); + root_child0_child0_child2.setMargin(Edge.Right, 4); + root_child0_child0_child2.setMargin(Edge.Bottom, 7); + root_child0_child0_child2.setPadding(Edge.Left, 5); + root_child0_child0_child2.setPadding(Edge.Top, 3); + root_child0_child0_child2.setPadding(Edge.Right, 8); + root_child0_child0_child2.setPadding(Edge.Bottom, 10); + root_child0_child0_child2.setBorder(Edge.Left, 2); + root_child0_child0_child2.setBorder(Edge.Top, 1); + root_child0_child0_child2.setBorder(Edge.Right, 5); + root_child0_child0_child2.setBorder(Edge.Bottom, 9); + root_child0_child0_child2.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setMargin(Edge.Left, 9); + root_child0_child0_child2_child0.setMargin(Edge.Top, 12); + root_child0_child0_child2_child0.setMargin(Edge.Right, 4); + root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child2_child0.setPadding(Edge.Left, 5); + root_child0_child0_child2_child0.setPadding(Edge.Top, 3); + root_child0_child0_child2_child0.setPadding(Edge.Right, 8); + root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child2_child0.setBorder(Edge.Left, 2); + root_child0_child0_child2_child0.setBorder(Edge.Top, 1); + root_child0_child0_child2_child0.setBorder(Edge.Right, 5); + root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child2_child0.setWidth(100); + root_child0_child0_child2_child0.setHeight(50); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(18); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(18); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(111); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(131); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(131); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); }); test('static_position_align_center_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setAlignItems(Align.Center); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0.setWidth("21%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0_child0.setWidth(100); - root_child0_child0_child0_child0.setHeight(50); - root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); - - const root_child0_child0_child1 = Yoga.Node.create(config); - root_child0_child0_child1.setMargin(Edge.Left, 9); - root_child0_child0_child1.setMargin(Edge.Top, 12); - root_child0_child0_child1.setMargin(Edge.Right, 4); - root_child0_child0_child1.setMargin(Edge.Bottom, 7); - root_child0_child0_child1.setPadding(Edge.Left, 5); - root_child0_child0_child1.setPadding(Edge.Top, 3); - root_child0_child0_child1.setPadding(Edge.Right, 8); - root_child0_child0_child1.setPadding(Edge.Bottom, 10); - root_child0_child0_child1.setBorder(Edge.Left, 2); - root_child0_child0_child1.setBorder(Edge.Top, 1); - root_child0_child0_child1.setBorder(Edge.Right, 5); - root_child0_child0_child1.setBorder(Edge.Bottom, 9); - root_child0_child0_child1.setWidth("10%"); - root_child0_child0.insertChild(root_child0_child0_child1, 1); - - const root_child0_child0_child1_child0 = Yoga.Node.create(config); - root_child0_child0_child1_child0.setMargin(Edge.Left, 9); - root_child0_child0_child1_child0.setMargin(Edge.Top, 12); - root_child0_child0_child1_child0.setMargin(Edge.Right, 4); - root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child1_child0.setPadding(Edge.Left, 5); - root_child0_child0_child1_child0.setPadding(Edge.Top, 3); - root_child0_child0_child1_child0.setPadding(Edge.Right, 8); - root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child1_child0.setBorder(Edge.Left, 2); - root_child0_child0_child1_child0.setBorder(Edge.Top, 1); - root_child0_child0_child1_child0.setBorder(Edge.Right, 5); - root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child1_child0.setWidth(100); - root_child0_child0_child1_child0.setHeight(50); - root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); - - const root_child0_child0_child2 = Yoga.Node.create(config); - root_child0_child0_child2.setMargin(Edge.Left, 9); - root_child0_child0_child2.setMargin(Edge.Top, 12); - root_child0_child0_child2.setMargin(Edge.Right, 4); - root_child0_child0_child2.setMargin(Edge.Bottom, 7); - root_child0_child0_child2.setPadding(Edge.Left, 5); - root_child0_child0_child2.setPadding(Edge.Top, 3); - root_child0_child0_child2.setPadding(Edge.Right, 8); - root_child0_child0_child2.setPadding(Edge.Bottom, 10); - root_child0_child0_child2.setBorder(Edge.Left, 2); - root_child0_child0_child2.setBorder(Edge.Top, 1); - root_child0_child0_child2.setBorder(Edge.Right, 5); - root_child0_child0_child2.setBorder(Edge.Bottom, 9); - root_child0_child0_child2.setWidth("10%"); - root_child0_child0.insertChild(root_child0_child0_child2, 2); - - const root_child0_child0_child2_child0 = Yoga.Node.create(config); - root_child0_child0_child2_child0.setMargin(Edge.Left, 9); - root_child0_child0_child2_child0.setMargin(Edge.Top, 12); - root_child0_child0_child2_child0.setMargin(Edge.Right, 4); - root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child2_child0.setPadding(Edge.Left, 5); - root_child0_child0_child2_child0.setPadding(Edge.Top, 3); - root_child0_child0_child2_child0.setPadding(Edge.Right, 8); - root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child2_child0.setBorder(Edge.Left, 2); - root_child0_child0_child2_child0.setBorder(Edge.Top, 1); - root_child0_child0_child2_child0.setBorder(Edge.Right, 5); - root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child2_child0.setWidth(100); - root_child0_child0_child2_child0.setHeight(50); - root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(215); - expect(root.getComputedHeight()).toBe(301); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(202); - expect(root_child0.getComputedHeight()).toBe(295); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(166); - expect(root_child0_child0.getComputedHeight()).toBe(244); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(65); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(39); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(75); - expect(root_child0_child0_child1.getComputedTop()).toBe(29); - expect(root_child0_child0_child1.getComputedWidth()).toBe(20); - expect(root_child0_child0_child1.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(75); - expect(root_child0_child0_child2.getComputedTop()).toBe(140); - expect(root_child0_child0_child2.getComputedWidth()).toBe(20); - expect(root_child0_child0_child2.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(215); - expect(root.getComputedHeight()).toBe(301); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(202); - expect(root_child0.getComputedHeight()).toBe(295); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(166); - expect(root_child0_child0.getComputedHeight()).toBe(244); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(65); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(39); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(75); - expect(root_child0_child0_child1.getComputedTop()).toBe(29); - expect(root_child0_child0_child1.getComputedWidth()).toBe(20); - expect(root_child0_child0_child1.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(75); - expect(root_child0_child0_child2.getComputedTop()).toBe(140); - expect(root_child0_child0_child2.getComputedWidth()).toBe(20); - expect(root_child0_child0_child2.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setAlignItems(Align.Center); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setMargin(Edge.Left, 9); + root_child0_child0_child1.setMargin(Edge.Top, 12); + root_child0_child0_child1.setMargin(Edge.Right, 4); + root_child0_child0_child1.setMargin(Edge.Bottom, 7); + root_child0_child0_child1.setPadding(Edge.Left, 5); + root_child0_child0_child1.setPadding(Edge.Top, 3); + root_child0_child0_child1.setPadding(Edge.Right, 8); + root_child0_child0_child1.setPadding(Edge.Bottom, 10); + root_child0_child0_child1.setBorder(Edge.Left, 2); + root_child0_child0_child1.setBorder(Edge.Top, 1); + root_child0_child0_child1.setBorder(Edge.Right, 5); + root_child0_child0_child1.setBorder(Edge.Bottom, 9); + root_child0_child0_child1.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setMargin(Edge.Left, 9); + root_child0_child0_child1_child0.setMargin(Edge.Top, 12); + root_child0_child0_child1_child0.setMargin(Edge.Right, 4); + root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child1_child0.setPadding(Edge.Left, 5); + root_child0_child0_child1_child0.setPadding(Edge.Top, 3); + root_child0_child0_child1_child0.setPadding(Edge.Right, 8); + root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child1_child0.setBorder(Edge.Left, 2); + root_child0_child0_child1_child0.setBorder(Edge.Top, 1); + root_child0_child0_child1_child0.setBorder(Edge.Right, 5); + root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child1_child0.setWidth(100); + root_child0_child0_child1_child0.setHeight(50); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setMargin(Edge.Left, 9); + root_child0_child0_child2.setMargin(Edge.Top, 12); + root_child0_child0_child2.setMargin(Edge.Right, 4); + root_child0_child0_child2.setMargin(Edge.Bottom, 7); + root_child0_child0_child2.setPadding(Edge.Left, 5); + root_child0_child0_child2.setPadding(Edge.Top, 3); + root_child0_child0_child2.setPadding(Edge.Right, 8); + root_child0_child0_child2.setPadding(Edge.Bottom, 10); + root_child0_child0_child2.setBorder(Edge.Left, 2); + root_child0_child0_child2.setBorder(Edge.Top, 1); + root_child0_child0_child2.setBorder(Edge.Right, 5); + root_child0_child0_child2.setBorder(Edge.Bottom, 9); + root_child0_child0_child2.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setMargin(Edge.Left, 9); + root_child0_child0_child2_child0.setMargin(Edge.Top, 12); + root_child0_child0_child2_child0.setMargin(Edge.Right, 4); + root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child2_child0.setPadding(Edge.Left, 5); + root_child0_child0_child2_child0.setPadding(Edge.Top, 3); + root_child0_child0_child2_child0.setPadding(Edge.Right, 8); + root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child2_child0.setBorder(Edge.Left, 2); + root_child0_child0_child2_child0.setBorder(Edge.Top, 1); + root_child0_child0_child2_child0.setBorder(Edge.Right, 5); + root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child2_child0.setWidth(100); + root_child0_child0_child2_child0.setHeight(50); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(65); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(39); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(75); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(75); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(65); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(39); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(75); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(75); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); }); test('static_position_align_flex_end_amalgamation', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setMargin(Edge.Left, 4); - root_child0.setMargin(Edge.Top, 5); - root_child0.setMargin(Edge.Right, 9); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 2); - root_child0.setPadding(Edge.Top, 9); - root_child0.setPadding(Edge.Right, 11); - root_child0.setPadding(Edge.Bottom, 13); - root_child0.setBorder(Edge.Left, 5); - root_child0.setBorder(Edge.Top, 6); - root_child0.setBorder(Edge.Right, 7); - root_child0.setBorder(Edge.Bottom, 8); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setAlignItems(Align.FlexEnd); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setMargin(Edge.Left, 8); - root_child0_child0.setMargin(Edge.Top, 6); - root_child0_child0.setMargin(Edge.Right, 3); - root_child0_child0.setMargin(Edge.Bottom, 9); - root_child0_child0.setPadding(Edge.Left, 1); - root_child0_child0.setPadding(Edge.Top, 7); - root_child0_child0.setPadding(Edge.Right, 9); - root_child0_child0.setPadding(Edge.Bottom, 4); - root_child0_child0.setBorder(Edge.Left, 8); - root_child0_child0.setBorder(Edge.Top, 10); - root_child0_child0.setBorder(Edge.Right, 2); - root_child0_child0.setBorder(Edge.Bottom, 1); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0.setWidth("21%"); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0_child0.setMargin(Edge.Left, 9); - root_child0_child0_child0_child0.setMargin(Edge.Top, 12); - root_child0_child0_child0_child0.setMargin(Edge.Right, 4); - root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child0_child0.setPadding(Edge.Left, 5); - root_child0_child0_child0_child0.setPadding(Edge.Top, 3); - root_child0_child0_child0_child0.setPadding(Edge.Right, 8); - root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child0_child0.setBorder(Edge.Left, 2); - root_child0_child0_child0_child0.setBorder(Edge.Top, 1); - root_child0_child0_child0_child0.setBorder(Edge.Right, 5); - root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child0_child0.setWidth(100); - root_child0_child0_child0_child0.setHeight(50); - root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); - - const root_child0_child0_child1 = Yoga.Node.create(config); - root_child0_child0_child1.setMargin(Edge.Left, 9); - root_child0_child0_child1.setMargin(Edge.Top, 12); - root_child0_child0_child1.setMargin(Edge.Right, 4); - root_child0_child0_child1.setMargin(Edge.Bottom, 7); - root_child0_child0_child1.setPadding(Edge.Left, 5); - root_child0_child0_child1.setPadding(Edge.Top, 3); - root_child0_child0_child1.setPadding(Edge.Right, 8); - root_child0_child0_child1.setPadding(Edge.Bottom, 10); - root_child0_child0_child1.setBorder(Edge.Left, 2); - root_child0_child0_child1.setBorder(Edge.Top, 1); - root_child0_child0_child1.setBorder(Edge.Right, 5); - root_child0_child0_child1.setBorder(Edge.Bottom, 9); - root_child0_child0_child1.setWidth("10%"); - root_child0_child0.insertChild(root_child0_child0_child1, 1); - - const root_child0_child0_child1_child0 = Yoga.Node.create(config); - root_child0_child0_child1_child0.setMargin(Edge.Left, 9); - root_child0_child0_child1_child0.setMargin(Edge.Top, 12); - root_child0_child0_child1_child0.setMargin(Edge.Right, 4); - root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child1_child0.setPadding(Edge.Left, 5); - root_child0_child0_child1_child0.setPadding(Edge.Top, 3); - root_child0_child0_child1_child0.setPadding(Edge.Right, 8); - root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child1_child0.setBorder(Edge.Left, 2); - root_child0_child0_child1_child0.setBorder(Edge.Top, 1); - root_child0_child0_child1_child0.setBorder(Edge.Right, 5); - root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child1_child0.setWidth(100); - root_child0_child0_child1_child0.setHeight(50); - root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); - - const root_child0_child0_child2 = Yoga.Node.create(config); - root_child0_child0_child2.setMargin(Edge.Left, 9); - root_child0_child0_child2.setMargin(Edge.Top, 12); - root_child0_child0_child2.setMargin(Edge.Right, 4); - root_child0_child0_child2.setMargin(Edge.Bottom, 7); - root_child0_child0_child2.setPadding(Edge.Left, 5); - root_child0_child0_child2.setPadding(Edge.Top, 3); - root_child0_child0_child2.setPadding(Edge.Right, 8); - root_child0_child0_child2.setPadding(Edge.Bottom, 10); - root_child0_child0_child2.setBorder(Edge.Left, 2); - root_child0_child0_child2.setBorder(Edge.Top, 1); - root_child0_child0_child2.setBorder(Edge.Right, 5); - root_child0_child0_child2.setBorder(Edge.Bottom, 9); - root_child0_child0_child2.setWidth("10%"); - root_child0_child0.insertChild(root_child0_child0_child2, 2); - - const root_child0_child0_child2_child0 = Yoga.Node.create(config); - root_child0_child0_child2_child0.setMargin(Edge.Left, 9); - root_child0_child0_child2_child0.setMargin(Edge.Top, 12); - root_child0_child0_child2_child0.setMargin(Edge.Right, 4); - root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); - root_child0_child0_child2_child0.setPadding(Edge.Left, 5); - root_child0_child0_child2_child0.setPadding(Edge.Top, 3); - root_child0_child0_child2_child0.setPadding(Edge.Right, 8); - root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); - root_child0_child0_child2_child0.setBorder(Edge.Left, 2); - root_child0_child0_child2_child0.setBorder(Edge.Top, 1); - root_child0_child0_child2_child0.setBorder(Edge.Right, 5); - root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); - root_child0_child0_child2_child0.setWidth(100); - root_child0_child0_child2_child0.setHeight(50); - root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(215); - expect(root.getComputedHeight()).toBe(301); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(202); - expect(root_child0.getComputedHeight()).toBe(295); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(166); - expect(root_child0_child0.getComputedHeight()).toBe(244); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(111); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(131); - expect(root_child0_child0_child1.getComputedTop()).toBe(29); - expect(root_child0_child0_child1.getComputedWidth()).toBe(20); - expect(root_child0_child0_child1.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(131); - expect(root_child0_child0_child2.getComputedTop()).toBe(140); - expect(root_child0_child0_child2.getComputedWidth()).toBe(20); - expect(root_child0_child0_child2.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(215); - expect(root.getComputedHeight()).toBe(301); - - expect(root_child0.getComputedLeft()).toBe(4); - expect(root_child0.getComputedTop()).toBe(5); - expect(root_child0.getComputedWidth()).toBe(202); - expect(root_child0.getComputedHeight()).toBe(295); - - expect(root_child0_child0.getComputedLeft()).toBe(15); - expect(root_child0_child0.getComputedTop()).toBe(21); - expect(root_child0_child0.getComputedWidth()).toBe(166); - expect(root_child0_child0.getComputedHeight()).toBe(244); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(18); - expect(root_child0_child0_child0.getComputedTop()).toBe(29); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); - expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child1.getComputedLeft()).toBe(18); - expect(root_child0_child0_child1.getComputedTop()).toBe(29); - expect(root_child0_child0_child1.getComputedWidth()).toBe(20); - expect(root_child0_child0_child1.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child0_child2.getComputedLeft()).toBe(18); - expect(root_child0_child0_child2.getComputedTop()).toBe(140); - expect(root_child0_child0_child2.getComputedWidth()).toBe(20); - expect(root_child0_child0_child2.getComputedHeight()).toBe(92); - - expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); - expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); - expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setAlignItems(Align.FlexEnd); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setMargin(Edge.Left, 9); + root_child0_child0_child1.setMargin(Edge.Top, 12); + root_child0_child0_child1.setMargin(Edge.Right, 4); + root_child0_child0_child1.setMargin(Edge.Bottom, 7); + root_child0_child0_child1.setPadding(Edge.Left, 5); + root_child0_child0_child1.setPadding(Edge.Top, 3); + root_child0_child0_child1.setPadding(Edge.Right, 8); + root_child0_child0_child1.setPadding(Edge.Bottom, 10); + root_child0_child0_child1.setBorder(Edge.Left, 2); + root_child0_child0_child1.setBorder(Edge.Top, 1); + root_child0_child0_child1.setBorder(Edge.Right, 5); + root_child0_child0_child1.setBorder(Edge.Bottom, 9); + root_child0_child0_child1.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setMargin(Edge.Left, 9); + root_child0_child0_child1_child0.setMargin(Edge.Top, 12); + root_child0_child0_child1_child0.setMargin(Edge.Right, 4); + root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child1_child0.setPadding(Edge.Left, 5); + root_child0_child0_child1_child0.setPadding(Edge.Top, 3); + root_child0_child0_child1_child0.setPadding(Edge.Right, 8); + root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child1_child0.setBorder(Edge.Left, 2); + root_child0_child0_child1_child0.setBorder(Edge.Top, 1); + root_child0_child0_child1_child0.setBorder(Edge.Right, 5); + root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child1_child0.setWidth(100); + root_child0_child0_child1_child0.setHeight(50); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setMargin(Edge.Left, 9); + root_child0_child0_child2.setMargin(Edge.Top, 12); + root_child0_child0_child2.setMargin(Edge.Right, 4); + root_child0_child0_child2.setMargin(Edge.Bottom, 7); + root_child0_child0_child2.setPadding(Edge.Left, 5); + root_child0_child0_child2.setPadding(Edge.Top, 3); + root_child0_child0_child2.setPadding(Edge.Right, 8); + root_child0_child0_child2.setPadding(Edge.Bottom, 10); + root_child0_child0_child2.setBorder(Edge.Left, 2); + root_child0_child0_child2.setBorder(Edge.Top, 1); + root_child0_child0_child2.setBorder(Edge.Right, 5); + root_child0_child0_child2.setBorder(Edge.Bottom, 9); + root_child0_child0_child2.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setMargin(Edge.Left, 9); + root_child0_child0_child2_child0.setMargin(Edge.Top, 12); + root_child0_child0_child2_child0.setMargin(Edge.Right, 4); + root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child2_child0.setPadding(Edge.Left, 5); + root_child0_child0_child2_child0.setPadding(Edge.Top, 3); + root_child0_child0_child2_child0.setPadding(Edge.Right, 8); + root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child2_child0.setBorder(Edge.Left, 2); + root_child0_child0_child2_child0.setBorder(Edge.Top, 1); + root_child0_child0_child2_child0.setBorder(Edge.Right, 5); + root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child2_child0.setWidth(100); + root_child0_child0_child2_child0.setHeight(50); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(111); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(131); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(131); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(18); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(18); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); }); test('static_position_static_root', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Static); - root.setPadding(Edge.Left, 6); - root.setPadding(Edge.Top, 1); - root.setPadding(Edge.Right, 11); - root.setPadding(Edge.Bottom, 4); - root.setWidth(100); - root.setHeight(200); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPositionType(PositionType.Absolute); - root_child0.setMargin(Edge.Left, 12); - root_child0.setMargin(Edge.Top, 11); - root_child0.setMargin(Edge.Right, 15); - root_child0.setMargin(Edge.Bottom, 1); - root_child0.setPadding(Edge.Left, 3); - root_child0.setPadding(Edge.Top, 7); - root_child0.setPadding(Edge.Right, 5); - root_child0.setPadding(Edge.Bottom, 4); - root_child0.setBorder(Edge.Left, 4); - root_child0.setBorder(Edge.Top, 3); - root_child0.setBorder(Edge.Right, 2); - root_child0.setBorder(Edge.Bottom, 1); - root_child0.setWidth("50%"); - root_child0.setHeight("50%"); - root.insertChild(root_child0, 0); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(18); - expect(root_child0.getComputedTop()).toBe(12); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(100); - expect(root.getComputedHeight()).toBe(200); - - expect(root_child0.getComputedLeft()).toBe(24); - expect(root_child0.getComputedTop()).toBe(12); - expect(root_child0.getComputedWidth()).toBe(50); - expect(root_child0.getComputedHeight()).toBe(100); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Static); + root.setPadding(Edge.Left, 6); + root.setPadding(Edge.Top, 1); + root.setPadding(Edge.Right, 11); + root.setPadding(Edge.Bottom, 4); + root.setWidth(100); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setMargin(Edge.Left, 12); + root_child0.setMargin(Edge.Top, 11); + root_child0.setMargin(Edge.Right, 15); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 3); + root_child0.setPadding(Edge.Top, 7); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 4); + root_child0.setBorder(Edge.Left, 4); + root_child0.setBorder(Edge.Top, 3); + root_child0.setBorder(Edge.Right, 2); + root_child0.setBorder(Edge.Bottom, 1); + root_child0.setWidth("50%"); + root_child0.setHeight("50%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(18); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(24); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); }); test('static_position_absolute_child_multiple', () => { const config = Yoga.Config.create(); - let root; - - try { - root = Yoga.Node.create(config); - root.setPositionType(PositionType.Absolute); - - const root_child0 = Yoga.Node.create(config); - root_child0.setPadding(Edge.Left, 100); - root_child0.setPadding(Edge.Top, 100); - root_child0.setPadding(Edge.Right, 100); - root_child0.setPadding(Edge.Bottom, 100); - root_child0.setWidth(400); - root_child0.setHeight(400); - root.insertChild(root_child0, 0); - - const root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setPositionType(PositionType.Static); - root_child0_child0.setWidth(100); - root_child0_child0.setHeight(100); - root_child0.insertChild(root_child0_child0, 0); - - const root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setPositionType(PositionType.Absolute); - root_child0_child0_child0.setWidth("10%"); - root_child0_child0_child0.setHeight(50); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - - const root_child0_child1 = Yoga.Node.create(config); - root_child0_child1.setPositionType(PositionType.Static); - root_child0_child1.setWidth(100); - root_child0_child1.setHeight(100); - root_child0.insertChild(root_child0_child1, 1); - - const root_child0_child1_child0 = Yoga.Node.create(config); - root_child0_child1_child0.setPositionType(PositionType.Absolute); - root_child0_child1_child0.setWidth("50%"); - root_child0_child1_child0.setHeight(50); - root_child0_child1.insertChild(root_child0_child1_child0, 0); - - const root_child0_child1_child1 = Yoga.Node.create(config); - root_child0_child1_child1.setPositionType(PositionType.Absolute); - root_child0_child1_child1.setWidth("50%"); - root_child0_child1_child1.setHeight(50); - root_child0_child1.insertChild(root_child0_child1_child1, 1); - - const root_child0_child2 = Yoga.Node.create(config); - root_child0_child2.setPositionType(PositionType.Absolute); - root_child0_child2.setWidth(25); - root_child0_child2.setHeight(50); - root_child0.insertChild(root_child0_child2, 2); - root.calculateLayout(undefined, undefined, Direction.LTR); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(100); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(0); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(100); - expect(root_child0_child1.getComputedTop()).toBe(200); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child1_child0.getComputedLeft()).toBe(0); - expect(root_child0_child1_child0.getComputedTop()).toBe(0); - expect(root_child0_child1_child0.getComputedWidth()).toBe(200); - expect(root_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1_child1.getComputedLeft()).toBe(0); - expect(root_child0_child1_child1.getComputedTop()).toBe(0); - expect(root_child0_child1_child1.getComputedWidth()).toBe(200); - expect(root_child0_child1_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(100); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - - root.calculateLayout(undefined, undefined, Direction.RTL); - - expect(root.getComputedLeft()).toBe(0); - expect(root.getComputedTop()).toBe(0); - expect(root.getComputedWidth()).toBe(400); - expect(root.getComputedHeight()).toBe(400); - - expect(root_child0.getComputedLeft()).toBe(0); - expect(root_child0.getComputedTop()).toBe(0); - expect(root_child0.getComputedWidth()).toBe(400); - expect(root_child0.getComputedHeight()).toBe(400); - - expect(root_child0_child0.getComputedLeft()).toBe(200); - expect(root_child0_child0.getComputedTop()).toBe(100); - expect(root_child0_child0.getComputedWidth()).toBe(100); - expect(root_child0_child0.getComputedHeight()).toBe(100); - - expect(root_child0_child0_child0.getComputedLeft()).toBe(60); - expect(root_child0_child0_child0.getComputedTop()).toBe(0); - expect(root_child0_child0_child0.getComputedWidth()).toBe(40); - expect(root_child0_child0_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1.getComputedLeft()).toBe(200); - expect(root_child0_child1.getComputedTop()).toBe(200); - expect(root_child0_child1.getComputedWidth()).toBe(100); - expect(root_child0_child1.getComputedHeight()).toBe(100); - - expect(root_child0_child1_child0.getComputedLeft()).toBe(-100); - expect(root_child0_child1_child0.getComputedTop()).toBe(0); - expect(root_child0_child1_child0.getComputedWidth()).toBe(200); - expect(root_child0_child1_child0.getComputedHeight()).toBe(50); - - expect(root_child0_child1_child1.getComputedLeft()).toBe(-100); - expect(root_child0_child1_child1.getComputedTop()).toBe(0); - expect(root_child0_child1_child1.getComputedWidth()).toBe(200); - expect(root_child0_child1_child1.getComputedHeight()).toBe(50); - - expect(root_child0_child2.getComputedLeft()).toBe(275); - expect(root_child0_child2.getComputedTop()).toBe(100); - expect(root_child0_child2.getComputedWidth()).toBe(25); - expect(root_child0_child2.getComputedHeight()).toBe(50); - } finally { - if (typeof root !== 'undefined') { - root.freeRecursive(); - } - - config.free(); - } + + const root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 100); + root_child0.setPadding(Edge.Top, 100); + root_child0.setPadding(Edge.Right, 100); + root_child0.setPadding(Edge.Bottom, 100); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth("10%"); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Static); + root_child0_child1.setWidth(100); + root_child0_child1.setHeight(100); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child1_child0.setPositionType(PositionType.Absolute); + root_child0_child1_child0.setWidth("50%"); + root_child0_child1_child0.setHeight(50); + root_child0_child1.insertChild(root_child0_child1_child0, 0); + + const root_child0_child1_child1 = Yoga.Node.create(config); + root_child0_child1_child1.setPositionType(PositionType.Absolute); + root_child0_child1_child1.setWidth("50%"); + root_child0_child1_child1.setHeight(50); + root_child0_child1.insertChild(root_child0_child1_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Absolute); + root_child0_child2.setWidth(25); + root_child0_child2.setHeight(50); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(100); + expect(root_child0_child1.getComputedTop()).toBe(200); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child1_child0.getComputedLeft()).toBe(0); + expect(root_child0_child1_child0.getComputedTop()).toBe(0); + expect(root_child0_child1_child0.getComputedWidth()).toBe(200); + expect(root_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1_child1.getComputedTop()).toBe(0); + expect(root_child0_child1_child1.getComputedWidth()).toBe(200); + expect(root_child0_child1_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(100); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(200); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(60); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(200); + expect(root_child0_child1.getComputedTop()).toBe(200); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child1_child0.getComputedLeft()).toBe(-100); + expect(root_child0_child1_child0.getComputedTop()).toBe(0); + expect(root_child0_child1_child0.getComputedWidth()).toBe(200); + expect(root_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1_child1.getComputedLeft()).toBe(-100); + expect(root_child0_child1_child1.getComputedTop()).toBe(0); + expect(root_child0_child1_child1.getComputedWidth()).toBe(200); + expect(root_child0_child1_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(275); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); }); diff --git a/website/src/components/YogaViewer.tsx b/website/src/components/YogaViewer.tsx index 193dd15fe7..43bc16a7fe 100644 --- a/website/src/components/YogaViewer.tsx +++ b/website/src/components/YogaViewer.tsx @@ -63,7 +63,6 @@ function layoutStyleTree( const layoutMetrics = metricsFromYogaNode(root); layoutMetrics.overflow = node.style?.overflow; - root.freeRecursive(); return layoutMetrics; }