From a6b869aeeaa230c006284b5f0cf9b4fab758d2e7 Mon Sep 17 00:00:00 2001 From: anders_k Date: Thu, 31 May 2018 20:54:35 +0000 Subject: [PATCH] Test !searchparse and !searchreplace git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6996 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/Tests/preprocessor.nsi | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/Source/Tests/preprocessor.nsi b/Source/Tests/preprocessor.nsi index 83e47b07..fb94c215 100644 --- a/Source/Tests/preprocessor.nsi +++ b/Source/Tests/preprocessor.nsi @@ -1,3 +1,5 @@ +### Preprocessor Tests ### + !ifndef file_is_included !define file_is_included @@ -233,6 +235,58 @@ PageExEnd !warning "You can't see me" ; "disable all" is still in effect !pragma warning pop + +!define ASSERT `!insertmacro ASSERT "${U+24}{__FILE__}" ${U+24}{__LINE__}` +!macro ASSERT __file __line __xpr +!if ${__xpr} +!else +!error `ASSERT: ${__xpr} (${__file}:${__line})` +!endif +!macroend + + +# test !searchparse +!searchparse "AbcDef" "Abc" OUT1 +${ASSERT} '${OUT1} S== "Def"' + +!define /redef OUT1 FAILED +!searchparse /noerrors "AbcDef" "FailThis" OUT1 +${ASSERT} '${OUT1} S== "FAILED"' + +!searchparse /ignorecase "AbcDef" "ABC" OUT1 +${ASSERT} '${OUT1} S== "Def"' + +!searchparse "AbcDef" "Ab" OUT1 "D" OUT2 +${ASSERT} '"${OUT1}${OUT2}" S== "cef"' + +!searchparse /ignorecase /file "${__FILE__}" "### " OUT1 " Tests" +${ASSERT} '${OUT1} == "Preprocessor"' + +!searchparse "AbcDef" "" OUT1 "Def" ; Empty first search string and chopping off the end without defining OUTPUTSYMBOL2 +${ASSERT} '${OUT1} S== "Abc"' + + +# test !searchreplace +!searchreplace OUT1 "FooBar" "Bar" "Baz" +${ASSERT} '${OUT1} S== "FooBaz"' + +!searchreplace OUT1 "FooBarBar" "Bar" "Baz" ; "replacing all instances" +${ASSERT} '${OUT1} S== "FooBazBaz"' + +!searchreplace OUT1 "FooBar" "BAR" "Baz" +${ASSERT} '${OUT1} S== "FooBar"' + +!searchreplace /ignorecase OUT1 "FooBar" "BAR" "Baz" +${ASSERT} '${OUT1} S== "FooBaz"' + +!searchreplace OUT1 "FooBar" "FailThis" "Baz" ; "allows you to redefine symbol_out without warning or error" +${ASSERT} '${OUT1} S== "FooBar"' + + +!verbose 4 +!echo "Completed tests" +!verbose 2 +!pragma whip 0 # EOF !else # this should just give a warning, not an error