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 -
|
Section "" ; empty string makes it hidden, so would starting with -
|
||||||
|
|
||||||
; write reg info
|
; write reg info
|
||||||
StrCpy $1 "POOOOOOOOOOOP"
|
StrCpy $1 "Hello World"
|
||||||
DetailPrint "I like to be able to see what is going on (debug) $1"
|
DetailPrint "I like to be able to see what is going on (debug) $1"
|
||||||
WriteRegStr HKLM SOFTWARE\NSISTest\BigNSISTest "Install_Dir" "$INSTDIR"
|
WriteRegStr HKLM SOFTWARE\NSISTest\BigNSISTest "Install_Dir" "$INSTDIR"
|
||||||
|
|
||||||
|
@ -149,6 +149,27 @@ SectionEnd
|
||||||
|
|
||||||
SectionGroup Group2
|
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"
|
Section "Test Branching"
|
||||||
|
|
||||||
BeginTestSection:
|
BeginTestSection:
|
||||||
|
|
|
@ -97,6 +97,16 @@ this shouldn't be compiled
|
||||||
!error "!if 'test' == 'test' is true!"
|
!error "!if 'test' == 'test' is true!"
|
||||||
!endif
|
!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 :)
|
; testing of two math functions and a macro hack :)
|
||||||
!define increase "!insertmacro increase"
|
!define increase "!insertmacro increase"
|
||||||
!macro increase DEFINE
|
!macro increase DEFINE
|
||||||
|
@ -133,21 +143,33 @@ ${increase} number3
|
||||||
!error "number5 != 1"
|
!error "number5 != 1"
|
||||||
!endif
|
!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
|
; end math functions
|
||||||
|
|
||||||
|
|
||||||
# this should just give a warning, not an error
|
# this should just give a warning, not an error
|
||||||
!include /NONFATAL file_that_doesnt_exist.nsh
|
!include /NONFATAL file_that_doesnt_exist.nsh
|
||||||
|
|
||||||
# this should include this file just one time.
|
# this should include this file just one time.
|
||||||
!include preprocessor.nsi
|
!include preprocessor.nsi
|
||||||
|
|
||||||
|
|
||||||
|
# test scopes
|
||||||
|
|
||||||
Section
|
Section
|
||||||
Return
|
Return
|
||||||
WriteUninstaller uninst.exe # avoid warning
|
WriteUninstaller uninst.exe # avoid warning
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
# test scopes
|
|
||||||
|
|
||||||
!macro TEST_SCOPE scope def should_exist
|
!macro TEST_SCOPE scope def should_exist
|
||||||
|
|
||||||
!if ${should_exist} == y
|
!if ${should_exist} == y
|
||||||
|
@ -220,6 +242,7 @@ PageExEnd
|
||||||
|
|
||||||
!insertmacro TEST_SCOPES "global" y n n n n
|
!insertmacro TEST_SCOPES "global" y n n n n
|
||||||
|
|
||||||
|
|
||||||
# test !pragma
|
# test !pragma
|
||||||
!pragma warning push
|
!pragma warning push
|
||||||
!pragma warning disable 7000
|
!pragma warning disable 7000
|
||||||
|
@ -236,15 +259,6 @@ PageExEnd
|
||||||
!pragma warning pop
|
!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
|
# test !searchparse
|
||||||
!searchparse "AbcDef" "Abc" OUT1
|
!searchparse "AbcDef" "Abc" OUT1
|
||||||
${ASSERT} '${OUT1} S== "Def"'
|
${ASSERT} '${OUT1} S== "Def"'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue