[λ] Make function expr tests be reactive to input

This lets us memoize more and test function expressions better
This commit is contained in:
Sathya Gunasekaran
2023-01-14 10:19:39 +00:00
parent e8cad1584c
commit 5fa3d41b22
8 changed files with 92 additions and 36 deletions
@@ -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;
};
@@ -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 () {
@@ -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;
@@ -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;