-
Notifications
You must be signed in to change notification settings - Fork 47.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compiler][test fixtures] Fork more fixtures for hir-rewrite
Followup from #30894 , not sure how these got missed. Note that this PR just copies the fixtures without adding `@enablePropagateDepsInHIR`. #31032 follows and actually enables the HIR-version of propagateScopeDeps to run. I split this out into two PRs to make snapshot differences easier to review, but also happy to merge Fixtures found from locally setting snap test runner to default to `enablePropagateDepsInHIR: 'enabled_baseline'` and forking fixtures files with different output. ghstack-source-id: 7d7cf41aa923d83ad49f89079171b0411923ce6b Pull Request resolved: #31030
- Loading branch information
Showing
29 changed files
with
1,504 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
...ures/compiler/propagate-scope-deps-hir-fork/conditional-break-labeled.expect.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
/** | ||
* props.b *does* influence `a` | ||
*/ | ||
function Component(props) { | ||
const a = []; | ||
a.push(props.a); | ||
label: { | ||
if (props.b) { | ||
break label; | ||
} | ||
a.push(props.c); | ||
} | ||
a.push(props.d); | ||
return a; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Component, | ||
params: ['TodoAdd'], | ||
isComponent: 'TodoAdd', | ||
}; | ||
|
||
``` | ||
|
||
## Code | ||
|
||
```javascript | ||
import { c as _c } from "react/compiler-runtime"; /** | ||
* props.b *does* influence `a` | ||
*/ | ||
function Component(props) { | ||
const $ = _c(2); | ||
let a; | ||
if ($[0] !== props) { | ||
a = []; | ||
a.push(props.a); | ||
bb0: { | ||
if (props.b) { | ||
break bb0; | ||
} | ||
|
||
a.push(props.c); | ||
} | ||
|
||
a.push(props.d); | ||
$[0] = props; | ||
$[1] = a; | ||
} else { | ||
a = $[1]; | ||
} | ||
return a; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Component, | ||
params: ["TodoAdd"], | ||
isComponent: "TodoAdd", | ||
}; | ||
|
||
``` | ||
21 changes: 21 additions & 0 deletions
21
...rc/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-break-labeled.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* props.b *does* influence `a` | ||
*/ | ||
function Component(props) { | ||
const a = []; | ||
a.push(props.a); | ||
label: { | ||
if (props.b) { | ||
break label; | ||
} | ||
a.push(props.c); | ||
} | ||
a.push(props.d); | ||
return a; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Component, | ||
params: ['TodoAdd'], | ||
isComponent: 'TodoAdd', | ||
}; |
197 changes: 197 additions & 0 deletions
197
...tures/compiler/propagate-scope-deps-hir-fork/conditional-early-return.expect.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
/** | ||
* props.b does *not* influence `a` | ||
*/ | ||
function ComponentA(props) { | ||
const a_DEBUG = []; | ||
a_DEBUG.push(props.a); | ||
if (props.b) { | ||
return null; | ||
} | ||
a_DEBUG.push(props.d); | ||
return a_DEBUG; | ||
} | ||
|
||
/** | ||
* props.b *does* influence `a` | ||
*/ | ||
function ComponentB(props) { | ||
const a = []; | ||
a.push(props.a); | ||
if (props.b) { | ||
a.push(props.c); | ||
} | ||
a.push(props.d); | ||
return a; | ||
} | ||
|
||
/** | ||
* props.b *does* influence `a`, but only in a way that is never observable | ||
*/ | ||
function ComponentC(props) { | ||
const a = []; | ||
a.push(props.a); | ||
if (props.b) { | ||
a.push(props.c); | ||
return null; | ||
} | ||
a.push(props.d); | ||
return a; | ||
} | ||
|
||
/** | ||
* props.b *does* influence `a` | ||
*/ | ||
function ComponentD(props) { | ||
const a = []; | ||
a.push(props.a); | ||
if (props.b) { | ||
a.push(props.c); | ||
return a; | ||
} | ||
a.push(props.d); | ||
return a; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: ComponentA, | ||
params: [{a: 1, b: false, d: 3}], | ||
}; | ||
|
||
``` | ||
|
||
## Code | ||
|
||
```javascript | ||
import { c as _c } from "react/compiler-runtime"; /** | ||
* props.b does *not* influence `a` | ||
*/ | ||
function ComponentA(props) { | ||
const $ = _c(3); | ||
let a_DEBUG; | ||
let t0; | ||
if ($[0] !== props) { | ||
t0 = Symbol.for("react.early_return_sentinel"); | ||
bb0: { | ||
a_DEBUG = []; | ||
a_DEBUG.push(props.a); | ||
if (props.b) { | ||
t0 = null; | ||
break bb0; | ||
} | ||
|
||
a_DEBUG.push(props.d); | ||
} | ||
$[0] = props; | ||
$[1] = a_DEBUG; | ||
$[2] = t0; | ||
} else { | ||
a_DEBUG = $[1]; | ||
t0 = $[2]; | ||
} | ||
if (t0 !== Symbol.for("react.early_return_sentinel")) { | ||
return t0; | ||
} | ||
return a_DEBUG; | ||
} | ||
|
||
/** | ||
* props.b *does* influence `a` | ||
*/ | ||
function ComponentB(props) { | ||
const $ = _c(2); | ||
let a; | ||
if ($[0] !== props) { | ||
a = []; | ||
a.push(props.a); | ||
if (props.b) { | ||
a.push(props.c); | ||
} | ||
|
||
a.push(props.d); | ||
$[0] = props; | ||
$[1] = a; | ||
} else { | ||
a = $[1]; | ||
} | ||
return a; | ||
} | ||
|
||
/** | ||
* props.b *does* influence `a`, but only in a way that is never observable | ||
*/ | ||
function ComponentC(props) { | ||
const $ = _c(3); | ||
let a; | ||
let t0; | ||
if ($[0] !== props) { | ||
t0 = Symbol.for("react.early_return_sentinel"); | ||
bb0: { | ||
a = []; | ||
a.push(props.a); | ||
if (props.b) { | ||
a.push(props.c); | ||
t0 = null; | ||
break bb0; | ||
} | ||
|
||
a.push(props.d); | ||
} | ||
$[0] = props; | ||
$[1] = a; | ||
$[2] = t0; | ||
} else { | ||
a = $[1]; | ||
t0 = $[2]; | ||
} | ||
if (t0 !== Symbol.for("react.early_return_sentinel")) { | ||
return t0; | ||
} | ||
return a; | ||
} | ||
|
||
/** | ||
* props.b *does* influence `a` | ||
*/ | ||
function ComponentD(props) { | ||
const $ = _c(3); | ||
let a; | ||
let t0; | ||
if ($[0] !== props) { | ||
t0 = Symbol.for("react.early_return_sentinel"); | ||
bb0: { | ||
a = []; | ||
a.push(props.a); | ||
if (props.b) { | ||
a.push(props.c); | ||
t0 = a; | ||
break bb0; | ||
} | ||
|
||
a.push(props.d); | ||
} | ||
$[0] = props; | ||
$[1] = a; | ||
$[2] = t0; | ||
} else { | ||
a = $[1]; | ||
t0 = $[2]; | ||
} | ||
if (t0 !== Symbol.for("react.early_return_sentinel")) { | ||
return t0; | ||
} | ||
return a; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: ComponentA, | ||
params: [{ a: 1, b: false, d: 3 }], | ||
}; | ||
|
||
``` | ||
### Eval output | ||
(kind: ok) [1,3] |
58 changes: 58 additions & 0 deletions
58
...src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-early-return.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* props.b does *not* influence `a` | ||
*/ | ||
function ComponentA(props) { | ||
const a_DEBUG = []; | ||
a_DEBUG.push(props.a); | ||
if (props.b) { | ||
return null; | ||
} | ||
a_DEBUG.push(props.d); | ||
return a_DEBUG; | ||
} | ||
|
||
/** | ||
* props.b *does* influence `a` | ||
*/ | ||
function ComponentB(props) { | ||
const a = []; | ||
a.push(props.a); | ||
if (props.b) { | ||
a.push(props.c); | ||
} | ||
a.push(props.d); | ||
return a; | ||
} | ||
|
||
/** | ||
* props.b *does* influence `a`, but only in a way that is never observable | ||
*/ | ||
function ComponentC(props) { | ||
const a = []; | ||
a.push(props.a); | ||
if (props.b) { | ||
a.push(props.c); | ||
return null; | ||
} | ||
a.push(props.d); | ||
return a; | ||
} | ||
|
||
/** | ||
* props.b *does* influence `a` | ||
*/ | ||
function ComponentD(props) { | ||
const a = []; | ||
a.push(props.a); | ||
if (props.b) { | ||
a.push(props.c); | ||
return a; | ||
} | ||
a.push(props.d); | ||
return a; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: ComponentA, | ||
params: [{a: 1, b: false, d: 3}], | ||
}; |
Oops, something went wrong.