-
Notifications
You must be signed in to change notification settings - Fork 47k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compiler][repro] Test fixture for fbt whitespace bug
ghstack-source-id: eaf31bc1cc1ecda3d29a292bf9592975d0307e6e Pull Request resolved: #30394
- Loading branch information
Showing
3 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
...src/__tests__/fixtures/compiler/fbt/bug-fbt-preserve-whitespace-param.expect.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
import fbt from "fbt"; | ||
|
||
/** | ||
* Currently fails with the following: | ||
* Found differences in evaluator results | ||
* Non-forget (expected): | ||
* (kind: ok) <div><span>Jason !</span></div> | ||
* Forget: | ||
* (kind: ok) <div><span>Jason!</span></div> | ||
*/ | ||
|
||
function Foo(props) { | ||
return ( | ||
// prettier-ignore | ||
<div> | ||
<fbt desc={"Dialog to show to user"}> | ||
<span> | ||
<fbt:param name="user name"> | ||
{props.name} | ||
</fbt:param> | ||
! | ||
</span> | ||
</fbt> | ||
</div> | ||
); | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Foo, | ||
params: [{ name: "Jason" }], | ||
}; | ||
|
||
``` | ||
|
||
## Code | ||
|
||
```javascript | ||
import { c as _c } from "react/compiler-runtime"; | ||
import fbt from "fbt"; | ||
|
||
/** | ||
* Currently fails with the following: | ||
* Found differences in evaluator results | ||
* Non-forget (expected): | ||
* (kind: ok) <div><span>Jason !</span></div> | ||
* Forget: | ||
* (kind: ok) <div><span>Jason!</span></div> | ||
*/ | ||
|
||
function Foo(props) { | ||
const $ = _c(2); | ||
let t0; | ||
if ($[0] !== props.name) { | ||
t0 = ( | ||
<div> | ||
{fbt._( | ||
"{=m0}", | ||
[ | ||
fbt._implicitParam( | ||
"=m0", | ||
<span> | ||
{fbt._( | ||
"{user name}!", | ||
[ | ||
fbt._param( | ||
"user name", | ||
|
||
props.name, | ||
), | ||
], | ||
{ hk: "mBBZ9" }, | ||
)} | ||
</span>, | ||
), | ||
], | ||
{ hk: "3RVfuk" }, | ||
)} | ||
</div> | ||
); | ||
$[0] = props.name; | ||
$[1] = t0; | ||
} else { | ||
t0 = $[1]; | ||
} | ||
return t0; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Foo, | ||
params: [{ name: "Jason" }], | ||
}; | ||
|
||
``` | ||
32 changes: 32 additions & 0 deletions
32
...-react-compiler/src/__tests__/fixtures/compiler/fbt/bug-fbt-preserve-whitespace-param.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import fbt from "fbt"; | ||
|
||
/** | ||
* Currently fails with the following: | ||
* Found differences in evaluator results | ||
* Non-forget (expected): | ||
* (kind: ok) <div><span>Jason !</span></div> | ||
* Forget: | ||
* (kind: ok) <div><span>Jason!</span></div> | ||
|
||
*/ | ||
|
||
function Foo(props) { | ||
return ( | ||
// prettier-ignore | ||
<div> | ||
<fbt desc={"Dialog to show to user"}> | ||
<span> | ||
<fbt:param name="user name"> | ||
{props.name} | ||
</fbt:param> | ||
! | ||
</span> | ||
</fbt> | ||
</div> | ||
); | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Foo, | ||
params: [{ name: "Jason" }], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters