Skip to content

Commit

Permalink
[compiler][test fixtures] Fork more fixtures for hir-rewrite
Browse files Browse the repository at this point in the history
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
mofeiZ committed Sep 30, 2024
1 parent 2d16326 commit 943e45e
Show file tree
Hide file tree
Showing 29 changed files with 1,504 additions and 0 deletions.
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",
};

```
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',
};
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]
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}],
};
Loading

0 comments on commit 943e45e

Please sign in to comment.