📄 t32bit.tpl
字号:
REM t32bit.tpl
REM EPOC OPL automatic test code for opler1 32-bit opcodes.
REM Copyright (c) 1991-2000 Symbian Ltd. All rights reserved.
DECLARE EXTERNAL
INCLUDE "Const.oph"
INCLUDE "hUtils.oph"
PROC Standalone:
REM Main procedure called when not running inside test harness.
LOADM KhUtils$
hLink:("t32bit", hThreadIdFromOplDoc&:, KhUserFull%)
REM After standalone completion, control returns here.
dINIT "Tests complete" :DIALOG
ENDP
proc t32bit:
rem hInitTestHarness:(KhInitLocalErrorHandling%, KhInitNotUsed%)
hRunTest%:("do32bit")
hCleanUp%:("CleanUp")
endp
PROC CleanUp:
TRAP DELETE "c:\t32bit\*.*"
TRAP RMDIR "c:\t32bit\"
ENDP
external doAlloc%:
external other32bitTests:
external assignToVarsAtHighMem:
external assignToVar%:(in%)
external assignToArrayItem%:(in%)
PROC do32BIT:
local p%
rem print "Opler1 32 bit addressing Tests"
rem pause 20
DEFAULTWIN KDefaultWin4KMode%
p%=doAlloc%: rem cell > 64k left in existence so other32bitTests
rem has all vars at memory > 64K
other32bitTests:
freeAlloc p%
rem print "Opler1 32 bit addressing Tests Finished OK"
rem pause 20
ENDP
PROC doAlloc%:
REM allocates cell > 64k
local p%,p2%
REM all the following ALLOC tests very inter-dependent
REM take extreme care when changing any of it
p%=ALLOC(70000)
if p%=0 : raise 10 : endif
pokeL p%,&12345678
if peekL(p%)<>&12345678 : raise 11 : endif
pokeL p%+70000-4,&87654321
pokeB p%+70000-5,&A9 rem after adjustAlloc, 70000-4 = &a9876543
if peekL(p%+70000-4)<>&87654321 : raise 12 : endif
p2%=AdjustAlloc(p%,2,1)
if p2%=0 : raise 13 : endif
p%=p2%
p2%=0
if peekW(p%+3)<>$1234 : raise 14 : endif
if peekW(p%)<>$5678 : raise 15 : endif
if peekL(p%+70000-4)<>&654321a9 : raise 16 : endif
if lenalloc(p%)<>70004 : raise 17 : endif
p2%=AdjustAlloc(p%,70000-4,-1)
if p2%=0 : raise 18 : endif
p%=p2%
p2%=0
if (peekL(p%+70000-5) and &ffffff00) <>&65432100 : raise 19 : endif
p2%=REALLOC(p%,70001)
if p2%=0 : raise 20 : endif
pokeb p%+70000,$21
if peekL(p%+70000-4)<>&87654321 : raise 21 : endif
return p%
ENDP
PROC other32BitTests:
local v%,v&,v,v$(255),v2$(255)
local ret%
local name$(255)
local p%,p2%
local h%
local arr(4)
local arr$(2,5)
local choice%,time&,ed$(30),xin$(8),file$(255),l&
local ev%(16)
local ev&(16)
local info%(10)
local gInfo&(48)
local stat%,stat&
local y%,m%,d%,hr%,mn%,s%,dd%
REM local fontn$(20)
local a%(16)
local p%(20),i%
rem Commands
v%=1234
if peekW(Addr(v%))<>1234 : raise 100 : endif
gFont KFontSquashed&
FONT KFontSquashed&, 0
FONT KFontCourierNormal11&,0
gCLOCK ON,11,0,"%H%:1%T",KFontSquashed& rem was font% on opl1993
pause 30
gCLOCK OFF
POKE$ addr(v$),"123" rem was addr% on Opl1993
if PEEK$(addr(v$))<>"123" : raise 1 : endif
POKEF addr(v), 1.23e99
if PEEKF(addr(v))<>1.23e99 : raise 2 : endif
POKEL addr(v&), &12345
if PEEKL(addr(v&))<>&12345 : raise 3 : endif
POKEW addr(v%), 32767
if PEEKW(addr(v%))<>32767 : raise 4 : endif
v%=256
POKEB addr(v%),255
if PEEKB(addr(v%)+1)<>1 : raise 5 : endif
rem Functions
name$="c:\t32bit\"
trap mkdir name$
ret%=IoOpen(h%,addr(name$),KIoOpenModeUnique% or KIoOpenFormatText% or KIoOpenAccessRandom%)
if ret%<0 : raise 6 : endif
v$="Check 32 bit addressing for IO functions - 123"
ret%=IOWRITE(h%,addr(v$)+1+KOplAlignment%,len(v$))
if ret%<0 : raise 7 : endif
v&=0 rem ignored (as on Opl1993)
ret%=ioseek(h%,6,v&)
if ret%<0 : raise 98 : endif
ioclose(h%)
ret%=ioopen(h%,name$,KIoOpenModeOpen% or KIoOpenFormatText%)
if ret%<0 : raise 97 : endif
ret%=IOREAD(h%,addr(v2$)+1+KOplAlignment%,len(v$)-2)
REM The IOREAD should return -43 indicating the text isn't correctly terminated.
REM However, it appears to read the length of the chars read, irrespective
REM of whether they're terminated.
if ret%<>-43
alert("F32 IoRead Error" + num$(ret%,5),err$(ret%))
raise 8
endif
ret%=len(v$)-2
pokeb addr(v2$),ret%
if v2$<>left$(v$,ret%)
print "Expecting v2$=[";v2$;"]"
print "Got [";left$(v$,ret%);"]"
raise 9
endif
ret%=ioclose(h%)
if ret%<0
raise 10
alert("IoClose Error",num$(ret%,5))
endif
rem trap unloadm "t_util"
rem Statistical functions
arr(1)=1
arr(2)=2
arr(3)=3
arr(4)=4
if MEAN(arr(),4)<>2.5 : raise 22 : endif
if SUM(arr(),4)<>10.0 : raise 23 : endif
if STD(arr(),3)<>1.0 : raise 24 : endif
if VAR(arr(),3)<>1.0 : raise 25 : endif
if MIN(arr(),4)<>1.0 : raise 26 : endif
if MAX(arr(),4)<>4.0 : raise 27 : endif
REM Interactive tests now in Interactive\tMain\t32bitI.tpl
y%=100 :m%=100 :d%=100
DAYSTODATE 396,y%,m%,d%
if y%<>1901 : raise 51 : endif
if m%<>2 : raise 52 : endif
if d%<>1 : raise 53 : endif
SECSTODATE 1234567890,y%,m%,d%,hr%,mn%,s%,dd%
if y%<>2009 or m%<>2 or d%<>13 or hr%<>23 or mn%<>31 or s%<>30 or dd%<>44
raise 54
endif
rem Grammar
assignToVarsAtHighMem:
rem SCREENINFO
v&=KFontCourierNormal11&
screeninfo info%()
if info%(1)<>0 : print info%(1) : raise 55 : endif REM
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -