-
Notifications
You must be signed in to change notification settings - Fork 32
E2E Tests for Query #585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wmccrthy
wants to merge
52
commits into
luau-lang:primary
Choose a base branch
from
wmccrthy:e2e-query-tests
base: primary
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
E2E Tests for Query #585
Changes from 38 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
4351412
add merge and foreach to tableext
wmccrthy 0d47b03
nit
wmccrthy e9c9f01
clean up
wmccrthy 6fa7a7b
add support for replacing tokens
wmccrthy ea6f9e5
e2e cases boiler plate
wmccrthy 009e6a1
query wrapper; overrides selectFromRoot so replacements are passed ar…
wmccrthy 39272ed
stylua
wmccrthy 33c3bd3
add apiRenameMigration case + repeated transform utils
wmccrthy 42f1814
func rename
wmccrthy 51d953e
use table.unpack
wmccrthy 3cbd48a
test case name change
wmccrthy cee4ee4
boilerplate for roact->react test case
wmccrthy 72959d5
Merge branch 'primary' into e2e-query-tests
wmccrthy 1cdcea9
update to work w/ primary branch changes to parser/printer/visitor
wmccrthy ab0ae3b
fully working roact->react transform + test case(s)
wmccrthy 2386e6f
Merge branch 'primary' into e2e-query-tests
wmccrthy 2846da7
Discard changes to lute/std/libs/syntax/printer.luau
wmccrthy 2fd76ca
add token printing back
wmccrthy fa1d1fb
remove comments + unused; nit cleanups
wmccrthy dcd144a
Merge branch 'primary' into e2e-query-tests
wmccrthy a5223cc
update to account for breaking changes
wmccrthy 3b17c80
slightly closer to snapshot tests
wmccrthy ca49ddc
slightly more organized transform output
wmccrthy 5231fba
Merge branch 'primary' into e2e-query-tests
wmccrthy 9999b21
restructure tests s.t cases are stored in snapshot files rather than …
wmccrthy 34aded2
restructure test to support file-based snapshots; gitignore transform…
wmccrthy 82b71f2
Discard changes to lute/std/libs/syntax/printer.luau
wmccrthy ac5da79
Delete tests/std/syntax/e2eCases/minimal_repro.luau
wmccrthy 96da218
remove api transform and use functional query style
wmccrthy 1eef702
fix some disgusting type errs
wmccrthy 041ebed
fix more type errs; remove comment
wmccrthy 18f73e7
add exists helper on query and update tests accordingly
wmccrthy 5b072d2
add tests for exists helper
wmccrthy f5499b1
use luau files for snapshots
wmccrthy 8076ed2
remove accidental print
wmccrthy d6d76b1
remove redundancies
wmccrthy 8dda54a
reorganize cases output according to feedbck
wmccrthy 3ed9211
add missing type
wmccrthy 56bc199
output git diff on test failure
wmccrthy 49a7e71
Merge branch 'primary' into e2e-query-tests
wmccrthy 3a7b52f
clean up nits from review
wmccrthy 7b72cce
Merge branch 'primary' into e2e-query-tests
wmccrthy 24fca16
Merge branch 'primary' into e2e-query-tests
wmccrthy 3746aa6
Merge branch 'e2e-query-tests' of https://github.com/wmccrthy/lute in…
wmccrthy 53c0989
use difftext in test
wmccrthy c16a9c1
use transform's output arg
wmccrthy bfbf400
apply first round of feedback
wmccrthy 9229b97
reformat to use fs.walk
wmccrthy 87c10c9
Merge branch 'primary' into e2e-query-tests
wmccrthy f12ba96
return type annotation instead of any annotation
wmccrthy 19f1a90
Merge branch 'primary' into e2e-query-tests
wmccrthy 523c56f
use line numbers in diff output
wmccrthy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -21,3 +21,5 @@ extern/*/ | |
| generated | ||
| **/generated-types.luau | ||
| WARP.md | ||
|
|
||
| **/**.luau.result | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,3 @@ | ||
| { | ||
| "languageMode": "nocheck" | ||
| } |
This file contains hidden or 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,3 @@ | ||
| local sameLibrary = require(packagesRoot.sameLibrary) | ||
|
|
||
| local result = sameLibrary.numFunc(1) |
3 changes: 3 additions & 0 deletions
3
tests/std/syntax/e2eCases/apiSurfaceChange/cases/case1.luau.expect
This file contains hidden or 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,3 @@ | ||
| local sameLibrary = require(packagesRoot.sameLibrary) | ||
|
|
||
| local result = sameLibrary.processNumber(1) |
This file contains hidden or 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,3 @@ | ||
| local sameLibrary = require(packagesRoot.sameLibrary) | ||
|
|
||
| local result = sameLibrary.arrayFunc({ 1, 2, 3 }) |
3 changes: 3 additions & 0 deletions
3
tests/std/syntax/e2eCases/apiSurfaceChange/cases/case2.luau.expect
This file contains hidden or 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,3 @@ | ||
| local sameLibrary = require(packagesRoot.sameLibrary) | ||
|
|
||
| local result = sameLibrary.processArray(table.unpack({ 1, 2, 3 })) |
This file contains hidden or 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,5 @@ | ||
| local sameLibrary = require(packagesRoot.sameLibrary) | ||
|
|
||
| local a = sameLibrary.numFunc(42) | ||
| local b = sameLibrary.arrayFunc({ 10, 20, 30 }) | ||
| local c = sameLibrary.stringFunc("hello") |
5 changes: 5 additions & 0 deletions
5
tests/std/syntax/e2eCases/apiSurfaceChange/cases/case3.luau.expect
This file contains hidden or 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,5 @@ | ||
| local sameLibrary = require(packagesRoot.sameLibrary) | ||
|
|
||
| local a = sameLibrary.processNumber(42) | ||
| local b = sameLibrary.processArray(table.unpack({ 10, 20, 30 })) | ||
| local c = sameLibrary.handleText("hello") |
This file contains hidden or 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,3 @@ | ||
| local sameLibrary = require(packagesRoot.sameLibrary) | ||
|
|
||
| local result = sameLibrary.numFunc(sameLibrary.getCount()) |
3 changes: 3 additions & 0 deletions
3
tests/std/syntax/e2eCases/apiSurfaceChange/cases/case4.luau.expect
This file contains hidden or 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,3 @@ | ||
| local sameLibrary = require(packagesRoot.sameLibrary) | ||
|
|
||
| local result = sameLibrary.processNumber(sameLibrary.retrieveCount()) |
This file contains hidden or 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,49 @@ | ||
| local luau = require("@lute/luau") | ||
| local utils = require("@std/syntax/utils") | ||
| local printer = require("@std/syntax/printer") | ||
| local qUtils = require("./utils") | ||
| local tableext = require("@std/tableext") | ||
| local query = require("@std/syntax/query") | ||
|
|
||
| local apiMap = { | ||
| numFunc = "processNumber", | ||
| stringFunc = "handleText", | ||
| arrayFunc = "processArray", | ||
| processData = "handleData", | ||
| getCount = "retrieveCount", | ||
| } | ||
|
|
||
| local argReplacements = { | ||
| arrayFunc = function(arg: luau.AstExpr) | ||
| return `table.unpack({printer.printnode(arg :: any)})` | ||
| end, | ||
| } | ||
|
|
||
| local function transformCallArgs(block: luau.AstStatBlock) | ||
| local argNodeToFuncName = {} :: { [luau.AstNode]: string } | ||
| return query | ||
| .findallfromroot(block, utils.isExprCall) | ||
| :filter(function(node: luau.AstExprCall) | ||
| return node.func.index and argReplacements[node.func.index.text] ~= nil | ||
| end) | ||
| :map(function(node: luau.AstExprCall) | ||
| local arg = node.arguments[1].node | ||
| argNodeToFuncName[arg] = (node.func :: luau.AstExprIndexName).index.text | ||
| return arg | ||
| end) | ||
| :replace(function(node: luau.AstExpr) | ||
| return (argReplacements[argNodeToFuncName[node]] :: (luau.AstExpr) -> string)(node) | ||
| end) | ||
| end | ||
|
|
||
| local function transform(ctx) | ||
| local parseresult = ctx.parseresult | ||
| local block = parseresult.root | ||
| local libAccessReplacements = qUtils.transformLibraryAccess(block, "sameLibrary", function(expr, index: luau.Token) | ||
| return `{printer.printnode(expr :: any)}.{apiMap[index.text]}` | ||
| end) | ||
| local argReplacements = transformCallArgs(block) | ||
| return tableext.combine(libAccessReplacements, argReplacements) | ||
| end | ||
|
|
||
| return transform | ||
This file contains hidden or 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,7 @@ | ||
| local types = require("./e2eCases/types") | ||
|
|
||
| return { | ||
| libraryMigration = require("./e2eCases/libraryMigration"), | ||
| apiSurfaceChange = require("./e2eCases/apiSurfaceChange"), | ||
| roactToReact = require("./e2eCases/roactToReact"), | ||
| } :: { [string]: types.e2e } |
This file contains hidden or 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,3 @@ | ||
| { | ||
| "languageMode": "nocheck" | ||
| } |
14 changes: 14 additions & 0 deletions
14
tests/std/syntax/e2eCases/libraryMigration/cases/case1.luau
This file contains hidden or 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,14 @@ | ||
| local oldLibrary = require(packagesRoot.old) | ||
|
|
||
| local function myDependentFunction(input: { string }): boolean | ||
| for _, s in input do | ||
| if oldLibrary.oldFunction(input) then | ||
| return true | ||
| end | ||
| end | ||
| return false | ||
| end | ||
|
|
||
| local function myIndexUsingDependentFunction(input: string): boolean | ||
| return oldLibrary.anotherFunction(input) | ||
| end |
14 changes: 14 additions & 0 deletions
14
tests/std/syntax/e2eCases/libraryMigration/cases/case1.luau.expect
This file contains hidden or 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,14 @@ | ||
| local newLibrary = require(packagesRoot.new) | ||
|
|
||
| local function myDependentFunction(input: { string }): boolean | ||
| for _, s in input do | ||
| if newLibrary.newFunction(input) then | ||
| return true | ||
| end | ||
| end | ||
| return false | ||
| end | ||
|
|
||
| local function myIndexUsingDependentFunction(input: string): boolean | ||
| return newLibrary.anotherNewFunction(input) | ||
| end |
This file contains hidden or 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,5 @@ | ||
| local oldLibraryDiffAlias = require(root.nested.packages.old) | ||
|
|
||
| local myEl = oldLibraryDiffAlias.oldFunction("lol") | ||
|
|
||
| return oldLibraryDiffAlias.anotherFunction(myEl) |
5 changes: 5 additions & 0 deletions
5
tests/std/syntax/e2eCases/libraryMigration/cases/case2.luau.expect
This file contains hidden or 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,5 @@ | ||
| local newLibrary = require(root.nested.packages.new) | ||
|
|
||
| local myEl = newLibrary.newFunction("lol") | ||
|
|
||
| return newLibrary.anotherNewFunction(myEl) |
This file contains hidden or 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,51 @@ | ||
| local types = require("@std/syntax/types") | ||
| local utils = require("@std/syntax/utils") | ||
| local qUtils = require("./utils") | ||
| local query = require("@std/syntax/query") | ||
| local tableext = require("@std/tableext") | ||
| local getRequireStatements = qUtils.getRequireStatements | ||
| local transformLibraryAccess = qUtils.transformLibraryAccess | ||
|
|
||
| local functionMap = { | ||
| ["oldFunction"] = "newFunction", | ||
| ["anotherFunction"] = "anotherNewFunction", | ||
| } | ||
|
|
||
| local function transformRequires(block: types.AstStatBlock): (string, types.replacements) | ||
| local oldLibRequires = getRequireStatements(block, "old") | ||
|
|
||
| local requireArgRepl = query | ||
| .findallfromroot(oldLibRequires.nodes[1] :: types.AstNode, utils.isExprCall) | ||
| :map(function(node: types.AstExprCall): types.Token? | ||
| if utils.isExprIndexName(node.arguments[1].node) ~= nil then | ||
| return node.arguments[1].node.index | ||
| end | ||
| return nil | ||
| end) | ||
| :replace(function(node) | ||
| return "new" | ||
| end) | ||
|
|
||
| local oldLibVar = oldLibRequires.nodes[1].variables[1].node | ||
| local oldLibAlias = "" | ||
| local requiredVarAliasRepl = query | ||
| .findallfromroot(oldLibVar :: any, utils.isToken) | ||
| :replace(function(node: types.Token) | ||
| oldLibAlias = node.text | ||
| return "newLibrary" | ||
| end) | ||
| return oldLibAlias, tableext.combine(requireArgRepl, requiredVarAliasRepl) | ||
| end | ||
|
|
||
| local function transform(ctx): types.replacements | ||
| local parseresult = ctx.parseresult | ||
| local block = parseresult.root | ||
| local oldLibAlias, requireRepl = transformRequires(block) | ||
| local libAccessRepl = transformLibraryAccess(block, oldLibAlias, function(_, index) | ||
| local oldFunction = index.text | ||
| return `newLibrary.{functionMap[oldFunction]}` | ||
| end) | ||
| return tableext.combine(requireRepl, libAccessRepl) | ||
| end | ||
|
|
||
| return transform |
This file contains hidden or 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,3 @@ | ||
| { | ||
| "languageMode": "nocheck" | ||
| } |
This file contains hidden or 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,3 @@ | ||
| local Roact = require(PackagesRoot.Roact) | ||
|
|
||
| return Roact.createFragment(arbitraryElement) |
3 changes: 3 additions & 0 deletions
3
tests/std/syntax/e2eCases/roactToReact/cases/case1.luau.expect
This file contains hidden or 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,3 @@ | ||
| local React = require(PackagesRoot.React) | ||
|
|
||
| return React.createElement(React.Fragment, nil, arbitraryElement) |
This file contains hidden or 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,3 @@ | ||
| local Roact = require(PackagesRoot.Roact) | ||
|
|
||
| return Roact.createElement(arbitraryElement, nil, Roact.oneChild(otherArbitraryElement)) |
11 changes: 11 additions & 0 deletions
11
tests/std/syntax/e2eCases/roactToReact/cases/case2.luau.expect
This file contains hidden or 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,11 @@ | ||
| local React = require(PackagesRoot.React) | ||
|
|
||
| return React.createElement( | ||
| arbitraryElement, | ||
| nil, | ||
| if not otherArbitraryElement | ||
| or not select(2, next(otherArbitraryElement)) | ||
| or next(otherArbitraryElement, table.pack(select(1, next(otherArbitraryElement) :: string))[1]) | ||
| then nil | ||
| else React.Children.only(select(2, next(otherArbitraryElement) :: any)) | ||
| ) |
This file contains hidden or 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,5 @@ | ||
| local Roact = require(PackagesRoot.Roact) | ||
|
|
||
| return Roact.createElement(Roact.Portal, { | ||
| target = arbitraryRoot, | ||
| }, children) |
3 changes: 3 additions & 0 deletions
3
tests/std/syntax/e2eCases/roactToReact/cases/case3.luau.expect
This file contains hidden or 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,3 @@ | ||
| local ReactRoblox = require(PackagesRoot.ReactRoblox) | ||
|
|
||
| return ReactRoblox.createPortal(children, arbitraryRoot) |
This file contains hidden or 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,6 @@ | ||
| local Roact = require(PackagesRoot.Roact) | ||
|
|
||
| return Roact.createElement(abitraryElement, { | ||
| [Roact.Ref] = arbitraryRef, | ||
| [Roact.Children] = arbitraryChildren, | ||
| }) |
6 changes: 6 additions & 0 deletions
6
tests/std/syntax/e2eCases/roactToReact/cases/case4.luau.expect
This file contains hidden or 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,6 @@ | ||
| local React = require(PackagesRoot.React) | ||
|
|
||
| return React.createElement(abitraryElement, { | ||
| ref = arbitraryRef, | ||
| children = arbitraryChildren, | ||
| }) |
This file contains hidden or 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,4 @@ | ||
| local Roact = require(PackagesRoot.Roact) | ||
|
|
||
| local instance = Roact.mount(element, nil, "Root") | ||
| Roact.unmount(instance) |
10 changes: 10 additions & 0 deletions
10
tests/std/syntax/e2eCases/roactToReact/cases/case5.luau.expect
This file contains hidden or 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,10 @@ | ||
| local ReactRoblox = require(PackagesRoot.ReactRoblox) | ||
|
|
||
| local root = ReactRoblox.createRoot(Instance.new("Folder")) | ||
| local actualParent = Instance.new("Folder") | ||
| local actualKey = "Root" | ||
| ReactRoblox.act(function() | ||
| root:render(ReactRoblox.createPortal({ [actualKey] = element } :: any, actualParent)) | ||
| end) | ||
| local instance = { root = root, parent = actualParent, key = actualKey } | ||
| instance.root:unmount() |
This file contains hidden or 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,5 @@ | ||
| local Roact = require(PackagesRoot.Roact) | ||
|
|
||
| local container = Instance.new("Folder") | ||
| local instance = Roact.mount(arbitraryElement, container) | ||
| Roact.update(instance, otherElement) |
13 changes: 13 additions & 0 deletions
13
tests/std/syntax/e2eCases/roactToReact/cases/case6.luau.expect
This file contains hidden or 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,13 @@ | ||
| local ReactRoblox = require(PackagesRoot.ReactRoblox) | ||
|
|
||
| local container = Instance.new("Folder") | ||
| local root = ReactRoblox.createRoot(Instance.new("Folder")) | ||
| local actualParent = container | ||
| local actualKey = "ReactRoot" | ||
| ReactRoblox.act(function() | ||
| root:render(ReactRoblox.createPortal({ [actualKey] = arbitraryElement } :: any, actualParent)) | ||
| end) | ||
| local instance = { root = root, parent = actualParent, key = actualKey } | ||
| ReactRoblox.act(function() | ||
| instance.root:render(ReactRoblox.createPortal({ [instance.key] = otherElement } :: any, instance.parent)) | ||
| end) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.