Added some integer tests
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6997 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
a6b869aeea
commit
565386c71f
2 changed files with 47 additions and 12 deletions
|
@ -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:
|
||||
|
|
|
@ -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"'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue