From b280db88dcdae900e9fd899ea49abfd5debe7c36 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 17 Jan 2023 03:32:46 +0100 Subject: [PATCH] Add more unit tests for function list Following the commit https://github.com/notepad-plus-plus/notepad-plus-plus/commit/7fad2a62d43eeaf6023046277e77fb260c9c54a3 --- PowerEditor/Test/FunctionList/autoit/unitTest | 8 +++++++ PowerEditor/Test/FunctionList/c/unitTest | 7 +++++++ PowerEditor/Test/FunctionList/cpp/unitTest | 12 +++++++++++ .../Test/FunctionList/javascript/unitTest | 5 +++++ PowerEditor/Test/FunctionList/php/unitTest | 11 +++++++++- .../Test/FunctionList/powershell/unitTest | 7 +++++++ PowerEditor/Test/FunctionList/rust/unitTest | 8 +++++++ PowerEditor/Test/FunctionList/sql/unitTest | 21 +++++++++++++++++-- .../Test/FunctionList/typescript/unitTest | 10 +++++++++ PowerEditor/Test/FunctionList/xml/unitTest | 3 +++ 10 files changed, 89 insertions(+), 3 deletions(-) diff --git a/PowerEditor/Test/FunctionList/autoit/unitTest b/PowerEditor/Test/FunctionList/autoit/unitTest index 195338d04..46b7ee84d 100644 --- a/PowerEditor/Test/FunctionList/autoit/unitTest +++ b/PowerEditor/Test/FunctionList/autoit/unitTest @@ -29,6 +29,14 @@ Func logoff() ; Start of the logoff function Exit ; Quit the program EndFunc ; End of the logoff Function +#CS +Func logoff() + GUISetState(@SW_HIDE) + Run("u:\logoff.bat") + Exit +EndFunc +#CE + Func cancel() ; Start of the cancel function GUISetState(@SW_HIDE) ; Hide the Window Exit ; Quit the program diff --git a/PowerEditor/Test/FunctionList/c/unitTest b/PowerEditor/Test/FunctionList/c/unitTest index 4334b0788..a4807734d 100644 --- a/PowerEditor/Test/FunctionList/c/unitTest +++ b/PowerEditor/Test/FunctionList/c/unitTest @@ -124,6 +124,13 @@ static void test() assert(fabsf(test_quat.q3 - quat.q3) < .01); } +/* +void commented_func() +{ + return; +} +*/ + int main() { test(); diff --git a/PowerEditor/Test/FunctionList/cpp/unitTest b/PowerEditor/Test/FunctionList/cpp/unitTest index f5865d087..9f901ae4a 100644 --- a/PowerEditor/Test/FunctionList/cpp/unitTest +++ b/PowerEditor/Test/FunctionList/cpp/unitTest @@ -516,6 +516,18 @@ int decStrVal(const TCHAR *str) return strVal(str, 10); } +/* +int commentedFunc1() +{ + return 1; +} +*/ + +/*int commentedFunc2() +{ + return 2; +}*/ + int hexStrVal(const TCHAR *str) { return strVal(str, 16); diff --git a/PowerEditor/Test/FunctionList/javascript/unitTest b/PowerEditor/Test/FunctionList/javascript/unitTest index e1b3d341c..f1d260f30 100644 --- a/PowerEditor/Test/FunctionList/javascript/unitTest +++ b/PowerEditor/Test/FunctionList/javascript/unitTest @@ -15,6 +15,11 @@ function extractKeywords(text) { filter(function(v, i, a) { return a.lastIndexOf(v) === i; }); } +/* +function commentedFunc() { + return 0; +} +*/ function convertBasicMarkup(input, allowHtml) { var strongRe = /[*]{2}([^*]+)[*]{2}/gm; diff --git a/PowerEditor/Test/FunctionList/php/unitTest b/PowerEditor/Test/FunctionList/php/unitTest index 32a4c6007..059a96bce 100644 --- a/PowerEditor/Test/FunctionList/php/unitTest +++ b/PowerEditor/Test/FunctionList/php/unitTest @@ -27,15 +27,24 @@ abstract class PageGrille extends PageMotsBleus{ return str_replace ( "\\" , "" , $pStr); } - function GetJavascriptMajax() { + function GetJavascriptMajax() { /* a block comment */ return "ABC"; } + /* + function commentedFunc1() { + return "commented 1"; + } + */ } function stringContainAsterisk_test1(){ $target = '/path/to/files/*'; } +/*function commentedFunc2(){ + return "commented 2"; +}*/ + function stringContainAsterisk_test2(){ $target = '/path/to/files/*.jpg'; } diff --git a/PowerEditor/Test/FunctionList/powershell/unitTest b/PowerEditor/Test/FunctionList/powershell/unitTest index f2f960b4f..306ec5e3b 100644 --- a/PowerEditor/Test/FunctionList/powershell/unitTest +++ b/PowerEditor/Test/FunctionList/powershell/unitTest @@ -14,6 +14,13 @@ function Clear-Host $host.PrivateData.ClearHost() } +<# +function Commented-Func +{ + return $s +} + #> + <# .SYNOPSIS Simple path completion function for PowerConsole. diff --git a/PowerEditor/Test/FunctionList/rust/unitTest b/PowerEditor/Test/FunctionList/rust/unitTest index 7159dce9b..5725df9a4 100644 --- a/PowerEditor/Test/FunctionList/rust/unitTest +++ b/PowerEditor/Test/FunctionList/rust/unitTest @@ -56,6 +56,14 @@ unsafe fn unsafe_example(n: u32) { } } +/* +unsafe fn commented_func(n: u32) { + for n in 1..n + 1 { + fizzbuzz(n); + } +} +*/ + // Declares a function with the "C" ABI extern "C" fn new_i32() -> i32 { 0 } diff --git a/PowerEditor/Test/FunctionList/sql/unitTest b/PowerEditor/Test/FunctionList/sql/unitTest index 966c2c201..7ddc9187d 100644 --- a/PowerEditor/Test/FunctionList/sql/unitTest +++ b/PowerEditor/Test/FunctionList/sql/unitTest @@ -5,7 +5,7 @@ FUNCTION hire (last_name VARCHAR2, job_id VARCHAR2, manager_id NUMBER, salary NUMBER, commission_pct NUMBER, department_id NUMBER) - RETURN NUMBER IS new_empno NUMBER; + RETURN NUMBER IS new_empno NUMBER; BEGIN SELECT employees_seq.NEXTVAL INTO new_empno @@ -69,5 +69,22 @@ PROCEDURE increase_comm(employee_id NUMBER, comm_incr NUMBER) IS SET commission_pct = commission_pct + comm_incr; END IF; END; -END emp_mgmt; +END emp_mgmt; +/* +PROCEDURE commented_func(employee_id NUMBER, comm_incr NUMBER) IS + curr_comm NUMBER; + BEGIN + SELECT commission_pct + INTO curr_comm + FROM employees + WHERE employees.employee_id = increase_comm.employee_id; + IF curr_comm IS NULL + THEN RAISE no_comm; + ELSE + UPDATE employees + SET commission_pct = commission_pct + comm_incr; + END IF; + END; +END emp_mgmt; +*/ / \ No newline at end of file diff --git a/PowerEditor/Test/FunctionList/typescript/unitTest b/PowerEditor/Test/FunctionList/typescript/unitTest index e1b3d341c..baad1fdac 100644 --- a/PowerEditor/Test/FunctionList/typescript/unitTest +++ b/PowerEditor/Test/FunctionList/typescript/unitTest @@ -15,6 +15,16 @@ function extractKeywords(text) { filter(function(v, i, a) { return a.lastIndexOf(v) === i; }); } +/* +function commentedFunc(text) { + if (!text) return []; + + return text. + split(/\s+/). + filter(function(v) { return v.length > 2; }). + filter(function(v, i, a) { return a.lastIndexOf(v) === i; }); +} +*/ function convertBasicMarkup(input, allowHtml) { var strongRe = /[*]{2}([^*]+)[*]{2}/gm; diff --git a/PowerEditor/Test/FunctionList/xml/unitTest b/PowerEditor/Test/FunctionList/xml/unitTest index 074381c79..172617d5b 100644 --- a/PowerEditor/Test/FunctionList/xml/unitTest +++ b/PowerEditor/Test/FunctionList/xml/unitTest @@ -1,6 +1,9 @@ + standard show