mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[λ] Make function expr tests be reactive to input
This lets us memoize more and test function expressions better
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function component() {
|
||||
let z = 100;
|
||||
function component(a) {
|
||||
let z = { a };
|
||||
let x = function () {
|
||||
z;
|
||||
};
|
||||
@@ -15,18 +15,32 @@ function component() {
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
function component() {
|
||||
function component(a) {
|
||||
const $ = React.useMemoCache();
|
||||
const z = 100;
|
||||
const c_0 = $[0] !== a;
|
||||
let z;
|
||||
if (c_0) {
|
||||
z = {
|
||||
a: a,
|
||||
};
|
||||
$[0] = a;
|
||||
$[1] = z;
|
||||
} else {
|
||||
z = $[1];
|
||||
}
|
||||
|
||||
const c_2 = $[2] !== z;
|
||||
let x;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
|
||||
if (c_2) {
|
||||
x = function () {
|
||||
z;
|
||||
};
|
||||
|
||||
$[0] = x;
|
||||
$[2] = z;
|
||||
$[3] = x;
|
||||
} else {
|
||||
x = $[0];
|
||||
x = $[3];
|
||||
}
|
||||
|
||||
return x;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function component() {
|
||||
let z = 100;
|
||||
function component(a) {
|
||||
let z = { a };
|
||||
let x = function () {
|
||||
z;
|
||||
};
|
||||
|
||||
+21
-7
@@ -2,8 +2,8 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function component() {
|
||||
let z = 100;
|
||||
function component(a) {
|
||||
let z = { a };
|
||||
let x;
|
||||
{
|
||||
x = function () {
|
||||
@@ -18,19 +18,33 @@ function component() {
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
function component() {
|
||||
function component(a) {
|
||||
const $ = React.useMemoCache();
|
||||
const z = 100;
|
||||
const c_0 = $[0] !== a;
|
||||
let z;
|
||||
if (c_0) {
|
||||
z = {
|
||||
a: a,
|
||||
};
|
||||
$[0] = a;
|
||||
$[1] = z;
|
||||
} else {
|
||||
z = $[1];
|
||||
}
|
||||
|
||||
const x = undefined;
|
||||
const c_2 = $[2] !== z;
|
||||
let x$0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
|
||||
if (c_2) {
|
||||
x$0 = function () {
|
||||
z;
|
||||
};
|
||||
|
||||
$[0] = x$0;
|
||||
$[2] = z;
|
||||
$[3] = x$0;
|
||||
} else {
|
||||
x$0 = $[0];
|
||||
x$0 = $[3];
|
||||
}
|
||||
|
||||
return x$0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function component() {
|
||||
let z = 100;
|
||||
function component(a) {
|
||||
let z = { a };
|
||||
let x;
|
||||
{
|
||||
x = function () {
|
||||
|
||||
+21
-7
@@ -2,8 +2,8 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function component() {
|
||||
let z = 100;
|
||||
function component(a) {
|
||||
let z = { a };
|
||||
let x = function () {
|
||||
{
|
||||
z;
|
||||
@@ -17,20 +17,34 @@ function component() {
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
function component() {
|
||||
function component(a) {
|
||||
const $ = React.useMemoCache();
|
||||
const z = 100;
|
||||
const c_0 = $[0] !== a;
|
||||
let z;
|
||||
if (c_0) {
|
||||
z = {
|
||||
a: a,
|
||||
};
|
||||
$[0] = a;
|
||||
$[1] = z;
|
||||
} else {
|
||||
z = $[1];
|
||||
}
|
||||
|
||||
const c_2 = $[2] !== z;
|
||||
let x;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
|
||||
if (c_2) {
|
||||
x = function () {
|
||||
{
|
||||
z;
|
||||
}
|
||||
};
|
||||
|
||||
$[0] = x;
|
||||
$[2] = z;
|
||||
$[3] = x;
|
||||
} else {
|
||||
x = $[0];
|
||||
x = $[3];
|
||||
}
|
||||
|
||||
return x;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function component() {
|
||||
let z = 100;
|
||||
function component(a) {
|
||||
let z = { a };
|
||||
let x = function () {
|
||||
{
|
||||
z;
|
||||
|
||||
+21
-7
@@ -2,8 +2,8 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function component() {
|
||||
let z = 100;
|
||||
function component(a) {
|
||||
let z = { a };
|
||||
let x = function () {
|
||||
(function () {
|
||||
z;
|
||||
@@ -17,20 +17,34 @@ function component() {
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
function component() {
|
||||
function component(a) {
|
||||
const $ = React.useMemoCache();
|
||||
const z = 100;
|
||||
const c_0 = $[0] !== a;
|
||||
let z;
|
||||
if (c_0) {
|
||||
z = {
|
||||
a: a,
|
||||
};
|
||||
$[0] = a;
|
||||
$[1] = z;
|
||||
} else {
|
||||
z = $[1];
|
||||
}
|
||||
|
||||
const c_2 = $[2] !== z;
|
||||
let x;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
|
||||
if (c_2) {
|
||||
x = function () {
|
||||
(function () {
|
||||
z;
|
||||
})();
|
||||
};
|
||||
|
||||
$[0] = x;
|
||||
$[2] = z;
|
||||
$[3] = x;
|
||||
} else {
|
||||
x = $[0];
|
||||
x = $[3];
|
||||
}
|
||||
|
||||
return x;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function component() {
|
||||
let z = 100;
|
||||
function component(a) {
|
||||
let z = { a };
|
||||
let x = function () {
|
||||
(function () {
|
||||
z;
|
||||
|
||||
Reference in New Issue
Block a user