Skip to content

Commit

Permalink
added testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexHaxe committed Nov 25, 2024
1 parent 94e8203 commit 3087cd2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/refactor/refactor/RefactorExtractMethodTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -521,4 +521,22 @@ class RefactorExtractMethodTest extends RefactorTestBase {
];
checkRefactor(RefactorExtractMethod, {fileName: "testcases/methods/TypeProcessor.hx", posStart: 113, posEnd: 221}, edits, async);
}

function testFunctionProcessor(async:Async) {
var edits:Array<TestEdit> = [
makeReplaceTestEdit("testcases/methods/FunctionProcessor.hx", "processExtract(callback, value, text);\n", 143, 211, true),
makeInsertTestEdit("testcases/methods/FunctionProcessor.hx",
"function processExtract(callback:(Int, String) -> Bool, value:Int, text:String) {\n"
+ "if (callback(value, text)) {\n"
+ " trace('Success: $value, $text');\n"
+ " }\n"
+ "}\n",
215, true),
];
addTypeHint("testcases/methods/FunctionProcessor.hx", 79,
FunctionType([LibType("Int", "Int", []), LibType("String", "String", [])], LibType("Bool", "Bool", [])));
addTypeHint("testcases/methods/FunctionProcessor.hx", 112, LibType("Int", "Int", []));
addTypeHint("testcases/methods/FunctionProcessor.hx", 129, LibType("String", "String", []));
checkRefactor(RefactorExtractMethod, {fileName: "testcases/methods/FunctionProcessor.hx", posStart: 142, posEnd: 211}, edits, async);
}
}
11 changes: 11 additions & 0 deletions testcases/methods/FunctionProcessor.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package testcases.methods;

class FunctionProcessor {
function process(callback:Int->String->Bool) {
var value = 42;
var text = "test";
if (callback(value, text)) {
trace('Success: $value, $text');
}
}
}

0 comments on commit 3087cd2

Please sign in to comment.