Skip to content

Commit

Permalink
improve #298; added failing test
Browse files Browse the repository at this point in the history
added f tests for #294 #295 #296 #298 #299 #300 #301
cleanup return tests
  • Loading branch information
Banaanae committed Oct 3, 2024
1 parent c77da98 commit f494252
Show file tree
Hide file tree
Showing 21 changed files with 150 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ConvertFuncs.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -4242,7 +4242,7 @@ FixByRefParams(ScriptString) {
Line := A_LoopField
replacement := false
for func, v in gmByRefParamMap {
if RegExMatch(Line, "(^|.*\W)\Q" func "\E\((.*)\)", &match) ; Nested functions break and cont. sections this
if RegExMatch(Line, "(^|.*\W)\Q" func "\E\((.*)\)(.*?)$", &match) ; Nested functions break and cont. sections this
&& !InStr(Line, "&") { ; Not defining a function
retLine := match[1] func "("
params := match[2]
Expand All @@ -4254,7 +4254,7 @@ FixByRefParams(ScriptString) {
}
params := StrReplace(params, MatchFuncParams[],,,, 1)
}
retLine := RTrim(retLine, ", ") ")"
retLine := RTrim(retLine, ", ") ")" match[3]
replacement := true
}
}
Expand Down
8 changes: 8 additions & 0 deletions tests/Failed conversions/ByRef_ex3.ah1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
MyFunc(ByRef a, ByRef b) {}

MyFunc(a, b)
MyFunc(a, b), a = b ; Stripped
MyFunc(a, b) ; Stripped

; MyFunc(a, b), Ord(1)
; MyFunc(a, b), MyFunc(a, b)
8 changes: 8 additions & 0 deletions tests/Failed conversions/ByRef_ex3.ah2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
MyFunc(&a, &b) {}

MyFunc(&a, &b)
MyFunc(&a, &b), a = b ; Stripped
MyFunc(&a, &b) ; Stripped

; MyFunc(a, b), Ord(1)
; MyFunc(a, b), MyFunc(a, b)
7 changes: 7 additions & 0 deletions tests/Failed conversions/DblQuoteMsgBox_ex1.ah1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
F1:: MsgBox % """" ; "
F2:: MsgBox % "abc""123" ; abc"123
F3:: MsgBox % "abc""123" MyFunc("", "123""abc") "" ; abc"123123"abc

MyFunc(a, b) {
return a b
}
7 changes: 7 additions & 0 deletions tests/Failed conversions/DblQuoteMsgBox_ex1.ah2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
F1::MsgBox("`"") ; "
F2::MsgBox("abc`"123") ; abc"123
F3::MsgBox("abc`"123" MyFunc("", "123`"abc") "") ; abc"123123"abc

MyFunc(a, b) {
return a b
}
18 changes: 18 additions & 0 deletions tests/Failed conversions/DllCall_ex12.ah1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var := DllCall("Func"
, "Str", "ABC" ; Comment
, "Str, "123" ; Comment
, "Str", "DEF") ;Comment

hCtrl := DllCall("CreateWindowEx"
, "Uint", 0x200 ; WS_EX_CLIENTEDGE
, "str", "HiEdit" ; ClassName
, "str", "" ; This line causes the issue
, "Uint", WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE | hStyle
, "int", X ; Left
, "int", Y ; Top
, "int", W ; Width
, "int", H ; Height
, "Uint", HParent ; hWndParent
, "Uint", MODULEID ; hMenu
, "Uint", 0 ; hInstance
, "Uint", 0, "Uint")
18 changes: 18 additions & 0 deletions tests/Failed conversions/DllCall_ex12.ah2
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var := DllCall("Func"
, "Str", "ABC" ; Comment
, "Str, "123" ; Comment
, "Str", "DEF") ;Comment

hCtrl := DllCall("CreateWindowEx"
, "Uint", 0x200 ; WS_EX_CLIENTEDGE
, "str", "HiEdit" ; ClassName
, "str", "" ; This line causes the issue
, "Uint", WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE | hStyle
, "int", X ; Left
, "int", Y ; Top
, "int", W ; Width
, "int", H ; Height
, "Uint", HParent ; hWndParent
, "Uint", MODULEID ; hMenu
, "Uint", 0 ; hInstance
, "Uint", 0, "Uint")
7 changes: 7 additions & 0 deletions tests/Failed conversions/GlobalGui_ex1.ah1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MyFunc() {
Gui, Add, Text,, Gui
Gui, Show, w150
}
MyFunc()

F1::Gui, Destroy
9 changes: 9 additions & 0 deletions tests/Failed conversions/GlobalGui_ex1.ah2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MyFunc() {
global ; V1toV2: Made function global
myGui := Gui()
myGui.Add("Text", , "Gui")
myGui.Show("w150")
}
MyFunc()

F1::myGui.Destroy()
18 changes: 18 additions & 0 deletions tests/Failed conversions/MsgBox_ex7.ah1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Switch Var
{
Case 1: MsgBox Test1
Case 2:
MsgBox Test2
}
IfMsgBox, Ok
MsgBox

Switch Var
{
Case 1:
MsgBox Test1
Case 2:
MsgBox Test2
}
IfMsgBox, Ok
MsgBox
18 changes: 18 additions & 0 deletions tests/Failed conversions/MsgBox_ex7.ah2
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Switch Var
{
Case 1: msgResult := MsgBox("Test1")
Case 2:
msgResult := MsgBox("Test2")
}
if (msgResult = "Ok")
MsgBox()

Switch Var
{
Case 1:
msgResult := MsgBox("Test1")
Case 2:
msgResult := MsgBox("Test2")
}
if (msgResult = "Ok")
MsgBox()
1 change: 1 addition & 0 deletions tests/Failed conversions/TernaryDblQuote_ex1.ah1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x := x = "" ? 0 : ""
1 change: 1 addition & 0 deletions tests/Failed conversions/TernaryDblQuote_ex1.ah2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x := x = "" ? 0 : ""
6 changes: 6 additions & 0 deletions tests/Failed conversions/static_ex1.ah1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
MyFunc() {
static var = 1
static var1=1,var2,var3=3
MsgBox % var
}
MyFunc()
6 changes: 6 additions & 0 deletions tests/Failed conversions/static_ex1.ah2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
MyFunc() {
static var := 1
static var1:=1,var2,var3:=3
MsgBox(var)
}
MyFunc()
5 changes: 5 additions & 0 deletions tests/Test_Folder/Flow of Control/ByRef_ex2.ah1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MyFunc(ByRef a, ByRef b) {}

MyFunc(a, b)
MyFunc(a, b), a = b ; Stripped
MyFunc(a, b) ; Stripped
5 changes: 5 additions & 0 deletions tests/Test_Folder/Flow of Control/ByRef_ex2.ah2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MyFunc(&a, &b) {}

MyFunc(&a, &b)
MyFunc(&a, &b), a = b ; Stripped
MyFunc(&a, &b) ; Stripped
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ MyFunc() {
Return, Trim(ToReturn, "Error")
}

MsgBox % MyFunc()
MsgBox % MyFunc()

MsgBox("Return, Test")
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ MyFunc() {
Return Trim(ToReturn, "Error")
}

MsgBox(MyFunc())
MsgBox(MyFunc())

MsgBox("Return, Test")
1 change: 0 additions & 1 deletion tests/Test_Folder/Flow of Control/Return_ex2.ah1

This file was deleted.

1 change: 0 additions & 1 deletion tests/Test_Folder/Flow of Control/Return_ex2.ah2

This file was deleted.

0 comments on commit f494252

Please sign in to comment.