mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[be][cleanup] Split primitive tests to individual fixtures
Followup to #1273 No changes, just moving test functions to their own fixture files.
This commit is contained in:
+79
@@ -0,0 +1,79 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// bar(props.b) is an allocating expression that produces a primitive, which means
|
||||
// that Forget should memoize it.
|
||||
// Correctness:
|
||||
// - y depends on either bar(props.b) or bar(props.b) + 1
|
||||
function AllocatingPrimitiveAsDepNested(props) {
|
||||
let x = {};
|
||||
mutate(x);
|
||||
let y = foo(bar(props.b) + 1);
|
||||
mutate(x, props.a);
|
||||
return [x, y];
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
// bar(props.b) is an allocating expression that produces a primitive, which means
|
||||
// that Forget should memoize it.
|
||||
// Correctness:
|
||||
// - y depends on either bar(props.b) or bar(props.b) + 1
|
||||
function AllocatingPrimitiveAsDepNested(props) {
|
||||
const $ = React.unstable_useMemoCache(11);
|
||||
const c_0 = $[0] !== props.b;
|
||||
const c_1 = $[1] !== props.a;
|
||||
let x;
|
||||
let y;
|
||||
if (c_0 || c_1) {
|
||||
x = {};
|
||||
mutate(x);
|
||||
const c_4 = $[4] !== props.b;
|
||||
let t0;
|
||||
if (c_4) {
|
||||
t0 = bar(props.b);
|
||||
$[4] = props.b;
|
||||
$[5] = t0;
|
||||
} else {
|
||||
t0 = $[5];
|
||||
}
|
||||
const t1 = t0 + 1;
|
||||
const c_6 = $[6] !== t1;
|
||||
let t2;
|
||||
if (c_6) {
|
||||
t2 = foo(t1);
|
||||
$[6] = t1;
|
||||
$[7] = t2;
|
||||
} else {
|
||||
t2 = $[7];
|
||||
}
|
||||
y = t2;
|
||||
mutate(x, props.a);
|
||||
$[0] = props.b;
|
||||
$[1] = props.a;
|
||||
$[2] = x;
|
||||
$[3] = y;
|
||||
} else {
|
||||
x = $[2];
|
||||
y = $[3];
|
||||
}
|
||||
const c_8 = $[8] !== x;
|
||||
const c_9 = $[9] !== y;
|
||||
let t3;
|
||||
if (c_8 || c_9) {
|
||||
t3 = [x, y];
|
||||
$[8] = x;
|
||||
$[9] = y;
|
||||
$[10] = t3;
|
||||
} else {
|
||||
t3 = $[10];
|
||||
}
|
||||
return t3;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// bar(props.b) is an allocating expression that produces a primitive, which means
|
||||
// that Forget should memoize it.
|
||||
// Correctness:
|
||||
// - y depends on either bar(props.b) or bar(props.b) + 1
|
||||
function AllocatingPrimitiveAsDepNested(props) {
|
||||
let x = {};
|
||||
mutate(x);
|
||||
let y = foo(bar(props.b) + 1);
|
||||
mutate(x, props.a);
|
||||
return [x, y];
|
||||
}
|
||||
@@ -11,14 +11,6 @@ function AllocatingPrimitiveAsDep(props) {
|
||||
return y;
|
||||
}
|
||||
|
||||
function PrimitiveAsDepNested(props) {
|
||||
let x = {};
|
||||
mutate(x);
|
||||
let y = foo(bar(props.b) + 1);
|
||||
mutate(x, props.a);
|
||||
return [x, y];
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
@@ -53,57 +45,5 @@ function AllocatingPrimitiveAsDep(props) {
|
||||
return y;
|
||||
}
|
||||
|
||||
function PrimitiveAsDepNested(props) {
|
||||
const $ = React.unstable_useMemoCache(11);
|
||||
const c_0 = $[0] !== props.b;
|
||||
const c_1 = $[1] !== props.a;
|
||||
let x;
|
||||
let y;
|
||||
if (c_0 || c_1) {
|
||||
x = {};
|
||||
mutate(x);
|
||||
const c_4 = $[4] !== props.b;
|
||||
let t0;
|
||||
if (c_4) {
|
||||
t0 = bar(props.b);
|
||||
$[4] = props.b;
|
||||
$[5] = t0;
|
||||
} else {
|
||||
t0 = $[5];
|
||||
}
|
||||
const t1 = t0 + 1;
|
||||
const c_6 = $[6] !== t1;
|
||||
let t2;
|
||||
if (c_6) {
|
||||
t2 = foo(t1);
|
||||
$[6] = t1;
|
||||
$[7] = t2;
|
||||
} else {
|
||||
t2 = $[7];
|
||||
}
|
||||
y = t2;
|
||||
mutate(x, props.a);
|
||||
$[0] = props.b;
|
||||
$[1] = props.a;
|
||||
$[2] = x;
|
||||
$[3] = y;
|
||||
} else {
|
||||
x = $[2];
|
||||
y = $[3];
|
||||
}
|
||||
const c_8 = $[8] !== x;
|
||||
const c_9 = $[9] !== y;
|
||||
let t3;
|
||||
if (c_8 || c_9) {
|
||||
t3 = [x, y];
|
||||
$[8] = x;
|
||||
$[9] = y;
|
||||
$[10] = t3;
|
||||
} else {
|
||||
t3 = $[10];
|
||||
}
|
||||
return t3;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
@@ -6,11 +6,3 @@ function AllocatingPrimitiveAsDep(props) {
|
||||
let y = foo(bar(props).b + 1);
|
||||
return y;
|
||||
}
|
||||
|
||||
function PrimitiveAsDepNested(props) {
|
||||
let x = {};
|
||||
mutate(x);
|
||||
let y = foo(bar(props.b) + 1);
|
||||
mutate(x, props.a);
|
||||
return [x, y];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// props.b + 1 is an non-allocating expression, which means Forget can
|
||||
// emit it trivially and repeatedly (e.g. no need to memoize props.b + 1
|
||||
// separately from props.b)
|
||||
// Correctness:
|
||||
// y depends on either props.b or props.b + 1
|
||||
function PrimitiveAsDepNested(props) {
|
||||
let x = {};
|
||||
mutate(x);
|
||||
let y = foo(props.b + 1);
|
||||
mutate(x, props.a);
|
||||
return [x, y];
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
// props.b + 1 is an non-allocating expression, which means Forget can
|
||||
// emit it trivially and repeatedly (e.g. no need to memoize props.b + 1
|
||||
// separately from props.b)
|
||||
// Correctness:
|
||||
// y depends on either props.b or props.b + 1
|
||||
function PrimitiveAsDepNested(props) {
|
||||
const $ = React.unstable_useMemoCache(9);
|
||||
const c_0 = $[0] !== props.b;
|
||||
const c_1 = $[1] !== props.a;
|
||||
let x;
|
||||
let y;
|
||||
if (c_0 || c_1) {
|
||||
x = {};
|
||||
mutate(x);
|
||||
const t0 = props.b + 1;
|
||||
const c_4 = $[4] !== t0;
|
||||
let t1;
|
||||
if (c_4) {
|
||||
t1 = foo(t0);
|
||||
$[4] = t0;
|
||||
$[5] = t1;
|
||||
} else {
|
||||
t1 = $[5];
|
||||
}
|
||||
y = t1;
|
||||
mutate(x, props.a);
|
||||
$[0] = props.b;
|
||||
$[1] = props.a;
|
||||
$[2] = x;
|
||||
$[3] = y;
|
||||
} else {
|
||||
x = $[2];
|
||||
y = $[3];
|
||||
}
|
||||
const c_6 = $[6] !== x;
|
||||
const c_7 = $[7] !== y;
|
||||
let t2;
|
||||
if (c_6 || c_7) {
|
||||
t2 = [x, y];
|
||||
$[6] = x;
|
||||
$[7] = y;
|
||||
$[8] = t2;
|
||||
} else {
|
||||
t2 = $[8];
|
||||
}
|
||||
return t2;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// props.b + 1 is an non-allocating expression, which means Forget can
|
||||
// emit it trivially and repeatedly (e.g. no need to memoize props.b + 1
|
||||
// separately from props.b)
|
||||
// Correctness:
|
||||
// y depends on either props.b or props.b + 1
|
||||
function PrimitiveAsDepNested(props) {
|
||||
let x = {};
|
||||
mutate(x);
|
||||
let y = foo(props.b + 1);
|
||||
mutate(x, props.a);
|
||||
return [x, y];
|
||||
}
|
||||
@@ -12,14 +12,6 @@ function PrimitiveAsDep(props) {
|
||||
return y;
|
||||
}
|
||||
|
||||
function PrimitiveAsDepNested(props) {
|
||||
let x = {};
|
||||
mutate(x);
|
||||
let y = foo(props.b + 1);
|
||||
mutate(x, props.a);
|
||||
return [x, y];
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
@@ -46,48 +38,5 @@ function PrimitiveAsDep(props) {
|
||||
return y;
|
||||
}
|
||||
|
||||
function PrimitiveAsDepNested(props) {
|
||||
const $ = React.unstable_useMemoCache(9);
|
||||
const c_0 = $[0] !== props.b;
|
||||
const c_1 = $[1] !== props.a;
|
||||
let x;
|
||||
let y;
|
||||
if (c_0 || c_1) {
|
||||
x = {};
|
||||
mutate(x);
|
||||
const t0 = props.b + 1;
|
||||
const c_4 = $[4] !== t0;
|
||||
let t1;
|
||||
if (c_4) {
|
||||
t1 = foo(t0);
|
||||
$[4] = t0;
|
||||
$[5] = t1;
|
||||
} else {
|
||||
t1 = $[5];
|
||||
}
|
||||
y = t1;
|
||||
mutate(x, props.a);
|
||||
$[0] = props.b;
|
||||
$[1] = props.a;
|
||||
$[2] = x;
|
||||
$[3] = y;
|
||||
} else {
|
||||
x = $[2];
|
||||
y = $[3];
|
||||
}
|
||||
const c_6 = $[6] !== x;
|
||||
const c_7 = $[7] !== y;
|
||||
let t2;
|
||||
if (c_6 || c_7) {
|
||||
t2 = [x, y];
|
||||
$[6] = x;
|
||||
$[7] = y;
|
||||
$[8] = t2;
|
||||
} else {
|
||||
t2 = $[8];
|
||||
}
|
||||
return t2;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
@@ -7,11 +7,3 @@ function PrimitiveAsDep(props) {
|
||||
let y = foo(props.b + 1);
|
||||
return y;
|
||||
}
|
||||
|
||||
function PrimitiveAsDepNested(props) {
|
||||
let x = {};
|
||||
mutate(x);
|
||||
let y = foo(props.b + 1);
|
||||
mutate(x, props.a);
|
||||
return [x, y];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user