Skip to content

Commit

Permalink
[compiler][be] Clean up bug test fixtures; evaluate more fixtures (#3…
Browse files Browse the repository at this point in the history
…1812)

Test fixtures testing different compiler features (e.g. non-auto
memoization) should live in separate directories.

Remove bug-prefixed fixtures that have since been fixed

Add test evaluator export to more fixtures
  • Loading branch information
mofeiZ authored Feb 18, 2025
1 parent a9575dc commit 86b1913
Show file tree
Hide file tree
Showing 43 changed files with 664 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,31 @@
## Input

```javascript
import {makeArray} from 'shared-runtime';

function Component(props) {
const x = foo(...props.a, null, ...props.b);
const x = makeArray(...props.a, null, ...props.b);
return x;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: [1, 2], b: [2, 3, 4]}],
};

```

## Code

```javascript
import { c as _c } from "react/compiler-runtime";
import { makeArray } from "shared-runtime";

function Component(props) {
const $ = _c(3);
let t0;
if ($[0] !== props.a || $[1] !== props.b) {
t0 = foo(...props.a, null, ...props.b);
t0 = makeArray(...props.a, null, ...props.b);
$[0] = props.a;
$[1] = props.b;
$[2] = t0;
Expand All @@ -28,5 +37,12 @@ function Component(props) {
return x;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ a: [1, 2], b: [2, 3, 4] }],
};

```
### Eval output
(kind: ok) [1,2,null,2,3,4]
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import {makeArray} from 'shared-runtime';

function Component(props) {
const x = foo(...props.a, null, ...props.b);
const x = makeArray(...props.a, null, ...props.b);
return x;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: [1, 2], b: [2, 3, 4]}],
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
## Input

```javascript
function component(foo, bar) {
import {mutate} from 'shared-runtime';

function Component({foo, bar}) {
let x = {foo};
let y = {bar};
const f0 = function () {
Expand All @@ -15,14 +17,28 @@ function component(foo, bar) {
return x;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{foo: 2, bar: 3}],
sequentialRenders: [
{foo: 2, bar: 3},
{foo: 2, bar: 3},
{foo: 2, bar: 4},
{foo: 3, bar: 4},
],
};

```

## Code

```javascript
import { c as _c } from "react/compiler-runtime";
function component(foo, bar) {
import { mutate } from "shared-runtime";

function Component(t0) {
const $ = _c(3);
const { foo, bar } = t0;
let x;
if ($[0] !== bar || $[1] !== foo) {
x = { foo };
Expand All @@ -44,5 +60,21 @@ function component(foo, bar) {
return x;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ foo: 2, bar: 3 }],
sequentialRenders: [
{ foo: 2, bar: 3 },
{ foo: 2, bar: 3 },
{ foo: 2, bar: 4 },
{ foo: 3, bar: 4 },
],
};

```
### Eval output
(kind: ok) {"foo":2}
{"foo":2}
{"foo":2}
{"foo":3}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
function component(foo, bar) {
import {mutate} from 'shared-runtime';

function Component({foo, bar}) {
let x = {foo};
let y = {bar};
const f0 = function () {
Expand All @@ -10,3 +12,14 @@ function component(foo, bar) {
mutate(y);
return x;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{foo: 2, bar: 3}],
sequentialRenders: [
{foo: 2, bar: 3},
{foo: 2, bar: 3},
{foo: 2, bar: 4},
{foo: 3, bar: 4},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
## Input

```javascript
function component(foo, bar) {
import {mutate} from 'shared-runtime';

function Component({foo, bar}) {
let x = {foo};
let y = {bar};
const f0 = function () {
Expand All @@ -15,14 +17,28 @@ function component(foo, bar) {
return x;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{foo: 2, bar: 3}],
sequentialRenders: [
{foo: 2, bar: 3},
{foo: 2, bar: 3},
{foo: 2, bar: 4},
{foo: 3, bar: 4},
],
};

```

## Code

```javascript
import { c as _c } from "react/compiler-runtime";
function component(foo, bar) {
import { mutate } from "shared-runtime";

function Component(t0) {
const $ = _c(3);
const { foo, bar } = t0;
let x;
if ($[0] !== bar || $[1] !== foo) {
x = { foo };
Expand All @@ -44,5 +60,21 @@ function component(foo, bar) {
return x;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ foo: 2, bar: 3 }],
sequentialRenders: [
{ foo: 2, bar: 3 },
{ foo: 2, bar: 3 },
{ foo: 2, bar: 4 },
{ foo: 3, bar: 4 },
],
};

```
### Eval output
(kind: ok) {"foo":2}
{"foo":2}
{"foo":2}
{"foo":3}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
function component(foo, bar) {
import {mutate} from 'shared-runtime';

function Component({foo, bar}) {
let x = {foo};
let y = {bar};
const f0 = function () {
Expand All @@ -10,3 +12,14 @@ function component(foo, bar) {
mutate(y);
return x;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{foo: 2, bar: 3}],
sequentialRenders: [
{foo: 2, bar: 3},
{foo: 2, bar: 3},
{foo: 2, bar: 4},
{foo: 3, bar: 4},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
## Input

```javascript
function component(foo, bar) {
import {mutate} from 'shared-runtime';
function Component({foo, bar}) {
let x = {foo};
let y = {bar};
const f0 = function () {
Expand All @@ -15,14 +16,27 @@ function component(foo, bar) {
return y;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{foo: 2, bar: 3}],
sequentialRenders: [
{foo: 2, bar: 3},
{foo: 2, bar: 3},
{foo: 2, bar: 4},
{foo: 3, bar: 4},
],
};

```

## Code

```javascript
import { c as _c } from "react/compiler-runtime";
function component(foo, bar) {
import { mutate } from "shared-runtime";
function Component(t0) {
const $ = _c(3);
const { foo, bar } = t0;
let y;
if ($[0] !== bar || $[1] !== foo) {
const x = { foo };
Expand All @@ -44,5 +58,21 @@ function component(foo, bar) {
return y;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ foo: 2, bar: 3 }],
sequentialRenders: [
{ foo: 2, bar: 3 },
{ foo: 2, bar: 3 },
{ foo: 2, bar: 4 },
{ foo: 3, bar: 4 },
],
};

```
### Eval output
(kind: ok) {"bar":3,"wat0":"joe"}
{"bar":3,"wat0":"joe"}
{"bar":4,"wat0":"joe"}
{"bar":4,"wat0":"joe"}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function component(foo, bar) {
import {mutate} from 'shared-runtime';
function Component({foo, bar}) {
let x = {foo};
let y = {bar};
const f0 = function () {
Expand All @@ -10,3 +11,14 @@ function component(foo, bar) {
mutate(y);
return y;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{foo: 2, bar: 3}],
sequentialRenders: [
{foo: 2, bar: 3},
{foo: 2, bar: 3},
{foo: 2, bar: 4},
{foo: 3, bar: 4},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
## Input

```javascript
function component(a) {
import {mutate} from 'shared-runtime';
function Component({a}) {
let x = {a};
let y = {};
const f0 = function () {
Expand All @@ -13,14 +14,22 @@ function component(a) {
return y;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2}],
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
};

```

## Code

```javascript
import { c as _c } from "react/compiler-runtime";
function component(a) {
import { mutate } from "shared-runtime";
function Component(t0) {
const $ = _c(2);
const { a } = t0;
let y;
if ($[0] !== a) {
const x = { a };
Expand All @@ -39,5 +48,15 @@ function component(a) {
return y;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ a: 2 }],
sequentialRenders: [{ a: 2 }, { a: 2 }, { a: 3 }],
};

```
### Eval output
(kind: ok) {"x":{"a":2},"wat0":"joe"}
{"x":{"a":2},"wat0":"joe"}
{"x":{"a":3},"wat0":"joe"}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function component(a) {
import {mutate} from 'shared-runtime';
function Component({a}) {
let x = {a};
let y = {};
const f0 = function () {
Expand All @@ -8,3 +9,9 @@ function component(a) {
mutate(y);
return y;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 2}],
sequentialRenders: [{a: 2}, {a: 2}, {a: 3}],
};
Loading

0 comments on commit 86b1913

Please sign in to comment.