Skip to content

Commit

Permalink
fix react test imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mmews committed Feb 8, 2024
1 parent 7ca06d6 commit 0e4609b
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Project "react" {
File "index.n4jsd" { from = "../react/index.n4jsd" }
File "index.js" { from = "../react/index.js" }
File "jsx-runtime.js" { from = "../react/jsx-runtime.js" }
File "package.json" { from = "../react/package.json" }
}
}
Expand All @@ -33,53 +34,48 @@
simple self-closing
{
"type": "div",
"props": null,
"children": []
"config": {}
}
simple open close
{
"type": "div",
"props": null,
"children": []
"config": {}
}
nested
{
"type": "div",
"props": {
"config": {
"prop1": true,
"prop2": "hello",
"prop3": 42
},
"children": [
42,
{
"type": "a",
"props": null,
"children": [
42
]
},
42,
{
"type": "p",
"props": null,
"children": []
}
]
"prop3": 42,
"children": [
42,
{
"type": "a",
"config": {
"children": 42
}
},
42,
{
"type": "p",
"config": {}
}
]
}
}
spead operator
{
"type": "div",
"props": {
"config": {
"prop0": "0",
"prop1": "hi",
"prop2": 42,
"prop3": true,
"prop4": "hi",
"prop5": 42,
"prop6": true
},
"children": []
}
}
--- */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Project "react" {
File "index.n4jsd" { from = "../react/index.n4jsd" }
File "index.js" { from = "../react/index.js" }
File "jsx-runtime.js" { from = "../react/jsx-runtime.js" }
File "package.json" { from = "../react/package.json" }
}
}
Expand All @@ -32,33 +33,30 @@
/* XPECT output ---
empty React fragment
{
"props": null,
"children": []
"config": {}
}
simple open close
{
"props": null,
"children": []
"config": {}
}
nested
{
"props": null,
"children": [
{
"type": "div",
"props": {
"prop1": "hello"
"config": {
"children": [
{
"type": "div",
"config": {
"prop1": "hello"
}
},
"children": []
},
{
"type": "div",
"props": {
"prop2": "world"
},
"children": []
}
]
{
"type": "div",
"config": {
"prop2": "world"
}
}
]
}
}
--- */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Project "react" {
File "index.n4jsd" { from = "../react/index.n4jsd" }
File "index.js" { from = "../react/index.js" }
File "jsx-runtime.js" { from = "../react/jsx-runtime.js" }
File "package.json" { from = "../react/package.json" }
}
}
Expand All @@ -33,10 +34,9 @@
Pure function element
{
"type": "PureFnComponent",
"props": {
"config": {
"myProp": "This is my propsss"
},
"children": []
}
}
--- */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Project "react" {
File "index.n4jsd" { from = "../react/index.n4jsd" }
File "index.js" { from = "../react/index.js" }
File "jsx-runtime.js" { from = "../react/jsx-runtime.js" }
File "package.json" { from = "../react/package.json" }
}
}
Expand All @@ -33,18 +34,16 @@
Lower component
{
"type": "LowerComponent",
"props": {
"config": {
"whatTextShouldIShow": "lcShadow"
},
"children": []
}
}
My component
{
"type": "MyComponent",
"props": {
"config": {
"aProp": "mcAPop"
},
"children": []
}
}
--- */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Project "react" {
File "index.n4jsd" { from = "../react/index.n4jsd" }
File "index.js" { from = "../react/index.js" }
File "jsx-runtime.js" { from = "../react/jsx-runtime.js" }
File "package.json" { from = "../react/package.json" }
}
}
Expand All @@ -32,12 +33,11 @@
/* XPECT output ---
{
"type": "MyReactFuncComponent",
"props": {
"config": {
"a": 1,
"x": 2,
"y": "Hi"
},
"children": []
}
}
--- */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Project "react" {
File "index.n4jsd" { from = "../react/index.n4jsd" }
File "index.js" { from = "../react/index.js" }
File "jsx-runtime.js" { from = "../react/jsx-runtime.js" }
File "package.json" { from = "../react/package.json" }
}
}
Expand All @@ -31,10 +32,10 @@
*/

/* XPECT output ---
r1.props[foo] == 1
r2.props[foo] == 2
r1.config[foo] == 1
r2.config[foo] == 2
i2[foo] == 0
o3.props[foo] == 3
o3.config[foo] == 3
d3[foo] == 0
--- */

Expand All @@ -45,14 +46,14 @@ zzzz;

let r1 : ~Object+ = <div { ...{foo: 0}} foo={1}/>;
// output --> 1
console.log("r1.props[foo] == " + r1.props["foo"]);
console.log("r1.config[foo] == " + r1.config["foo"]);



let i2 = {foo: 0, bar : 0};
let r2 : ~Object+ = <div { ...i2} foo={2} />;
// output --> 2
console.log("r2.props[foo] == " + r2.props["foo"]);
console.log("r2.config[foo] == " + r2.config["foo"]);

// output --> 0
console.log("i2[foo] == " + i2["foo"]);
Expand All @@ -66,7 +67,7 @@ let d3 : D+ = new D();
let o3 : ~Object+ = <div { ...d3} foo={3} />;

// output --> 3
console.log("o3.props[foo] == " + o3.props["foo"]);
console.log("o3.config[foo] == " + o3.config["foo"]);

// output --> 0
console.log("d3[foo] == " + d3["foo"]);
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Project "react" {
File "index.n4jsd" { from = "../react/index.n4jsd" }
File "index.js" { from = "../react/index.js" }
File "jsx-runtime.js" { from = "../react/jsx-runtime.js" }
File "package.json" { from = "../react/package.json" }
}
}
Expand All @@ -42,57 +43,51 @@ const baz = { baz: "MyBaz" }
Zero attribute:
{
"type": "div",
"props": null,
"children": []
"config": {}
}
One property attribute:
{
"type": "div",
"props": {
"config": {
"foo": "Hi"
},
"children": []
}
}
One spread:
{
"type": "div",
"props": {
"config": {
"baz": "MyBaz"
},
"children": []
}
}
Spread as first attribute:
{
"type": "div",
"props": {
"config": {
"baz": "MyBaz",
"foo": true,
"qux": "tt",
"tux": 5
},
"children": []
}
}
Spread between props:
{
"type": "div",
"props": {
"config": {
"foo": true,
"baz": "MyBaz",
"qux": "tt",
"tux": 5
},
"children": []
}
}
Spread as last attribute:
{
"type": "div",
"props": {
"config": {
"foo": true,
"qux": "tt",
"tux": 5,
"baz": "MyBaz"
},
"children": []
}
}
--- */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Project "react" {
File "index.n4jsd" { from = "../react/index.n4jsd" }
File "index.js" { from = "../react/index.js" }
File "jsx-runtime.js" { from = "../react/jsx-runtime.js" }
File "package.json" { from = "../react/package.json" }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Project "react" {
File "index.n4jsd" { from = "../react/index.n4jsd" }
File "index.js" { from = "../react/index.js" }
File "jsx-runtime.js" { from = "../react/jsx-runtime.js" }
File "package.json" { from = "../react/package.json" }
}
}
Expand Down Expand Up @@ -78,15 +79,15 @@ const props4 = {
a1: 1,
a2: 2
};
const MyDiv4 = $jsx('div', Object.assign(props4, {
const MyDiv4 = $jsx('div', Object.assign({}, props4, {
ref: "x"
}), 1);
MyDiv4;
const props5 = {
a1: 1,
a2: 2
};
const MyDiv5 = $jsx('div', Object.assign(props5, props4, {
const MyDiv5 = $jsx('div', Object.assign({}, props5, props4, {
ref: "x"
}), 1);
MyDiv5;
Expand Down

0 comments on commit 0e4609b

Please sign in to comment.