From 060ae1de67cf19c5a0913c3c05d0340df23d5172 Mon Sep 17 00:00:00 2001 From: guest3456 Date: Fri, 23 Dec 2016 09:23:03 -0500 Subject: [PATCH] convert SplitPath closes issue #24 --- ConvertFuncs.ahk | 1 + tests/Tests.ahk | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/ConvertFuncs.ahk b/ConvertFuncs.ahk index 2ee9d12a..c96ee83b 100644 --- a/ConvertFuncs.ahk +++ b/ConvertFuncs.ahk @@ -54,6 +54,7 @@ Convert(ScriptString) SetEnv,var,valueT2E | {1} := {2} Sleep,DelayCBE2T | Sleep, {1} Sort,var,options | Sort, {1}, `%{1}`%, {2} + SplitPath,varCBE2T,filename,dir,ext,name_no_ext,drv | SplitPath, {1}, {2}, {3}, {4}, {5}, {6} StringLen,OutputVar,InputVar | {1} := StrLen({2}) StringGetPos,OutputVar,InputVar,SearchTextT2E,SideT2E,OffsetCBE2E | *_StringGetPos StringMid,OutputVar,InputVar,StartCharCBE2E,CountCBE2E,L_T2E | *_StringMid diff --git a/tests/Tests.ahk b/tests/Tests.ahk index c48d965d..e255eedd 100644 --- a/tests/Tests.ahk +++ b/tests/Tests.ahk @@ -4896,6 +4896,100 @@ WHICH WOULD MEAN WE'D NEED THE FULL COMMAND LIST. Yunit.assert(converted = expected, "converted output script != expected output script") } + SplitPath() + { + input_script := " + (Join`r`n % + FullFileName = C:\My Documents\Address List.txt + SplitPath, FullFileName, name + SplitPath, FullFileName, , dir + FileAppend, %name%``n%dir%, * + )" + + expected := " + (Join`r`n % + FullFileName := "C:\My Documents\Address List.txt" + SplitPath, %FullFileName%, name + SplitPath, %FullFileName%, , dir + FileAppend, %name%``n%dir%, * + )" + + ; first test that our expected code actually produces the same results in v2 + ;result_input := ExecScript_v1(input_script) + ;result_expected := ExecScript_v2(expected) + ;MsgBox, 'input_script' results (v1):`n[%result_input%]`n`n'expected' results (v2):`n[%result_expected%] + ;Yunit.assert(result_input = result_expected, "input v1 execution != expected v2 execution") + + ; then test that our converter will correctly covert the input_script to the expected script + converted := Convert(input_script) + ;FileAppend, % expected, expected.txt + ;FileAppend, % converted, converted.txt + ;Run, ..\diff\VisualDiff.exe ..\diff\VisualDiff.ahk "%A_ScriptDir%\expected.txt" "%A_ScriptDir%\converted.txt" + Yunit.assert(converted = expected, "converted output script != expected output script") + } + + SplitPath_expr_var() + { + input_script := " + (Join`r`n % + FullFileName = C:\My Documents\Address List.txt + SplitPath, % FullFileName, name + SplitPath, % FullFileName, , dir + FileAppend, %name%``n%dir%, * + )" + + expected := " + (Join`r`n % + FullFileName := "C:\My Documents\Address List.txt" + SplitPath, % FullFileName, name + SplitPath, % FullFileName, , dir + FileAppend, %name%``n%dir%, * + )" + + ; first test that our expected code actually produces the same results in v2 + ;result_input := ExecScript_v1(input_script) + ;result_expected := ExecScript_v2(expected) + ;MsgBox, 'input_script' results (v1):`n[%result_input%]`n`n'expected' results (v2):`n[%result_expected%] + ;Yunit.assert(result_input = result_expected, "input v1 execution != expected v2 execution") + + ; then test that our converter will correctly covert the input_script to the expected script + converted := Convert(input_script) + ;FileAppend, % expected, expected.txt + ;FileAppend, % converted, converted.txt + ;Run, ..\diff\VisualDiff.exe ..\diff\VisualDiff.ahk "%A_ScriptDir%\expected.txt" "%A_ScriptDir%\converted.txt" + Yunit.assert(converted = expected, "converted output script != expected output script") + } + + SplitPath_expr_str() + { + input_script := " + (Join`r`n % + SplitPath, % "C:\My Documents\Address List.txt", name + SplitPath, % "C:\My Documents\Address List.txt", , dir + FileAppend, %name%``n%dir%, * + )" + + expected := " + (Join`r`n % + SplitPath, % "C:\My Documents\Address List.txt", name + SplitPath, % "C:\My Documents\Address List.txt", , dir + FileAppend, %name%``n%dir%, * + )" + + ; first test that our expected code actually produces the same results in v2 + ;result_input := ExecScript_v1(input_script) + ;result_expected := ExecScript_v2(expected) + ;MsgBox, 'input_script' results (v1):`n[%result_input%]`n`n'expected' results (v2):`n[%result_expected%] + ;Yunit.assert(result_input = result_expected, "input v1 execution != expected v2 execution") + + ; then test that our converter will correctly covert the input_script to the expected script + converted := Convert(input_script) + ;FileAppend, % expected, expected.txt + ;FileAppend, % converted, converted.txt + ;Run, ..\diff\VisualDiff.exe ..\diff\VisualDiff.ahk "%A_ScriptDir%\expected.txt" "%A_ScriptDir%\converted.txt" + Yunit.assert(converted = expected, "converted output script != expected output script") + } + End() { }