From 565386c71f80ac6afb4d53e769c49a67cf7ba41a Mon Sep 17 00:00:00 2001 From: anders_k Date: Fri, 1 Jun 2018 16:33:13 +0000 Subject: [PATCH] Added some integer tests git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6997 212acab6-be3b-0410-9dea-997c60f758d6 --- Examples/bigtest.nsi | 23 +++++++++++++++++++++- Source/Tests/preprocessor.nsi | 36 ++++++++++++++++++++++++----------- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/Examples/bigtest.nsi b/Examples/bigtest.nsi index eee2a476..8a56a54f 100644 --- a/Examples/bigtest.nsi +++ b/Examples/bigtest.nsi @@ -67,7 +67,7 @@ ShowInstDetails show Section "" ; empty string makes it hidden, so would starting with - ; write reg info - StrCpy $1 "POOOOOOOOOOOP" + StrCpy $1 "Hello World" DetailPrint "I like to be able to see what is going on (debug) $1" WriteRegStr HKLM SOFTWARE\NSISTest\BigNSISTest "Install_Dir" "$INSTDIR" @@ -149,6 +149,27 @@ SectionEnd SectionGroup Group2 +!define ASSERT `!insertmacro ASSERT "${U+24}{__FILE__}" ${U+24}{__LINE__} ` +!macro ASSERT __file __line __xpr +${__xpr} +2 +MessageBox MB_ICONSTOP `ASSERT: ${__xpr} (${__file}:${__line})` +!macroend + +Section "Integer" +IntOp $0 0xffffffff >> 31 +${ASSERT} `IntCmpU $0 -1` +IntOp $0 0xffffffff >>> 31 +${ASSERT} `IntCmpU $0 1` +IntOp $0 1 << 31 +${ASSERT} `IntCmpU $0 0x80000000` +IntOp $0 0x80000000 ^ 0x40000000 +${ASSERT} `IntCmpU $0 0xC0000000` +ClearErrors +IntOp $0 1 / 0 +${ASSERT} `IfErrors ` ; Division by zero must set the error flag +${ASSERT} `IntCmpU $0 0` ; Unspecified result, hopefully it's zero +SectionEnd + Section "Test Branching" BeginTestSection: diff --git a/Source/Tests/preprocessor.nsi b/Source/Tests/preprocessor.nsi index fb94c215..c04a64a3 100644 --- a/Source/Tests/preprocessor.nsi +++ b/Source/Tests/preprocessor.nsi @@ -97,6 +97,16 @@ this shouldn't be compiled !error "!if 'test' == 'test' is true!" !endif + +!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 + + ; testing of two math functions and a macro hack :) !define increase "!insertmacro increase" !macro increase DEFINE @@ -133,21 +143,33 @@ ${increase} number3 !error "number5 != 1" !endif +!define /redef /math OUT1 0xffffffff >> 31 +${ASSERT} '${OUT1} = -1' +!define /redef /math OUT1 0xffffffff >>> 31 +${ASSERT} '${OUT1} = 1' +!define /redef /math OUT1 1 << 31 +${ASSERT} '${OUT1} = 0x80000000' + +!define /redef /math OUT1 0x80000000 ^ 0x40000000 +${ASSERT} '${OUT1} = 0xC0000000' + ; end math functions + # this should just give a warning, not an error !include /NONFATAL file_that_doesnt_exist.nsh # this should include this file just one time. !include preprocessor.nsi + +# test scopes + Section Return WriteUninstaller uninst.exe # avoid warning SectionEnd -# test scopes - !macro TEST_SCOPE scope def should_exist !if ${should_exist} == y @@ -220,6 +242,7 @@ PageExEnd !insertmacro TEST_SCOPES "global" y n n n n + # test !pragma !pragma warning push !pragma warning disable 7000 @@ -236,15 +259,6 @@ PageExEnd !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"'