⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plb_dbas.tpl

📁 在手机操作系统symbina上使用的一个脚本扩展语言的代码实现,可以参考用于自己的开发
💻 TPL
📖 第 1 页 / 共 2 页
字号:
REM plb_Dbas.tpl
REM EPOC OPL automatic test code for DBMS
REM Copyright (c) 1991-2000 Symbian Ltd. All rights reserved.

INCLUDE "hUtils.oph"

PROC Standalone:
	REM Main procedure called when not running inside test harness.
	LOADM KhUtils$
	hLink:("plb_dbas", hThreadIdFromOplDoc&:, KhUserFull%)
	REM After standalone completion, control returns here.
	dINIT "Tests complete" :DIALOG
ENDP

PROC pLB_DBAS:
	rem hInitTestHarness:(KhInitLocalErrorHandling%, KhInitNotUsed%)
	hRunTest%:("plb_dbas1")
	hCleanUp%:("CleanUp")
ENDP

CONST KPath$="c:\"

PROC CleanUp:
	global path$(32)
	path$=KPath$
	TRAP CLOSE
	TRAP CLOSE
	TRAP CLOSE
	TRAP CLOSE
	DELETE path$+"Ben.dbf"
	DELETE path$+"Benb.dbf"
	DELETE path$+"Modify.dbf"
	DELETE path$+"Position.dbf"
ENDP

proc pLB_DBAS1:
  global exp%,val%,te%,te$(32)
  global path$(32)
  local c%,d%
  path$=kpath$
  REM print" Tests for LB_DBASE compatibity "
  IF exist (path$+"BEN.dbf")
 		delete path$+"BEN.dbf"
 	ENDIF

  IF exist (path$+"BENB.dbf")
 		delete path$+"BENB.dbf"
 	ENDIF

  create path$+"BEN.dbf",C, string1$,string2$,long&,int%,float
  create path$+"BENB.dbf",D,string1$,string2$,long&,int%,float

  onerr e1
  REM print "testing err: 'file/device in use' new behaviour"
  trap open path$+"BENB.dbf",a,string1$,string2$,long&,int%,float
e1::
	onerr off
	if err<>0 rem File in use
		REM print "Got unexpected error", err,err$(err)
		hLog%:(KhLogAlways%,"Part 1 error="+ERR$(ERR))
		raise 1
	endif

onerr e2
  REM print "testing err: 'file not exist'"
  open path$+"notexist.dbf",b,nam$,no%
  REM print "Failed to get error"
e2::
	onerr off
	if err<>-33 rem File NOT EXIST
		REM print "Got unexpected error", err,err$(err)
		raise 2
	endif


  REM print"testing count pos eof"
  use C

  te%=1
  val%=count
  exp%=0
  test:

  te%=2
  val%=pos
  exp%=1
  test:

  te%=3
  val%=eof
  exp%=-1
  test:

  c%=1
  while C%<10
     C.long&=c%*int(1001)
     C.string1$="dbase c"
     C.int%=C%
     c.float=C%*3.1457
     append
     c%=c%+1
  ENDWH

  te%=4
  val%=count
  exp%=9
  test:

  te%=5
  val%=pos
  exp%=9
  test:

  te%=6
  val%=eof
  exp%=0
  test:

  first

  te%=7
  val%=count
  exp%=9
  test:

  te%=8
  val%=pos
  exp%=1
  test:

  te%=9
  val%=eof
  exp%=0
  test:

  last

  te%=10
  val%=count
  exp%=9
  test:

  te%=11
  val%=pos
  exp%=9
  test:

  te%=12
  val%=eof
  exp%=0
  test:

  next
  te%=13
  val%=count
  exp%=9
  test:

  te%=14
  val%=pos
  exp%=10
  test:

  te%=15
  val%=eof
  exp%=-1
  test:

  first

  c%=1
  while C%<10
     d.long&=C.long&
     d.string1$="dbase d"
     d.string2$=c.string1$
     d.int%=C.int%
     d.float=c.float
     use d
     append
     use c
     next
     c%=c%+1
   ENDWH

REM print "testing Append Update and navigation"

  use d
  te%=16
  val%=count
  exp%=9
  test:

  first
  back

  te%=17
  val%=pos
  exp%=1
  test:

  first
  te%=18
  val%=find("dba?e c")
  exp%=1
  test:


  te%=19
  val%=find(" dd")
  exp%=0
  test:

  te%=20
  val%=eof
  exp%=-1
  test:

  position 4

  te%=21
  val%=pos
  exp%=4
  test:

  te%=22
  val%=d.int%
  exp%=4
  test:

  d.string2$="dbase c updated"
  use c
  first
  use d
  update
  first

  te%=23
  val%=find("*up*")
  exp%=9
  test:

  d.string2$="dbase c updated2"

  position 9

  update

  te%=24
  val%=find("*d2")
  exp%=0
  test:

  position 10

  te%=25
  val%=eof
  exp%=-1
  test:

  te%=24
  val%=find("*d2")
  exp%=0                  rem inserted to tests to check for finding from eof
  test:

  te%=25
  val%=eof
  exp%=-1
  test:

  position 0

  te%=26
  val%=pos
  exp%=1
  test:

  position 100

  te%=27
  val%=pos
  exp%=10
  test:

 REM print"testing find functions"
  te%=28
  val%=findfield("dbase C",1,1,2)
  exp%=0
  test:   rem should be zero

  te%=29
  val%=pos
  exp%=1
  test:

  te%=30
  val%=findfield("dbas? C",1,2,2)
  exp%=8
  test:

  te%=31
  val%=findfield("dbas? C",2,1,2)
  exp%=8
  test:

  te%=301  rem  ****** inserted extension
  val%=pos
  exp%=8
  test:

  d.string1$="BEN"
  append

  last
  next

  te%=302
  val%=eof
  exp%=-1
  test:

  te%=303
  val%=findfield("BEN",1,1,2)
  exp%=count
  test:

  last
  next

  te%=304
  val%=eof
  exp%=-1
  test:

  back
  te%=305
  val%=findfield("BeN",1,1,16)
  exp%=0
  test:

  te%=306
  val%=pos
  exp%=1
  test:
  last
  next


  te%=307
  val%=eof
  exp%=-1
  test:

  te%=308
  val%=pos
  exp%=count+1
  test:

  te%=309
  val%=findfield("BEN",1,1,0)
  exp%=count
  test:

last
next
  te%=310
  val%=findfield("BEN",1,1,1)
  exp%=0
  test:

  te%=311
  val%=pos
  exp%=count+1
  test:

  back
  erase
  close
  close

onerr e3
  REM print "testing err: 'argument error'"
  open path$+"BENB.dbf",a,nam$,no%
  REM print "Failed to get error"
e3::
	onerr off
	if err<>-2 rem WRONG ARGS
		REM print "Got unexpected error", err,err$(err)
		raise 3
	endif

onerr e4
  REM print "testing err: 'file not open'"
  a.nam$="s"
  REM print "Failed to get error"
e4::
	onerr off
	if err<>-102 rem File not open
		REM print "Got unexpected error", err,err$(err)
		raise 4
	endif



  open path$+"BENB.dbf",b,a$,b$,c&,d%,e	

  te%=32
  val%=count
  exp%=9
  test:

  te%=33
  val%=pos
  exp%=1
  test:

 erase
  te%=34
  val%=pos
  exp%=1
  test:

  te%=35
  val%=count
  exp%=8
  test:
 position 5
  te%=36
  val%=pos
  exp%=5
  test:

 erase
  te%=37
  val%=pos
  exp%=5
  test:

  te%=38
  val%=count
  exp%=7
  test:

 last
  te%=39
  val%=pos
  exp%=7
  test:

 erase
  te%=40
  val%=pos
  exp%=7
  test:

  te%=41
  val%=count
  exp%=6
  test:

  last
  next

  te%=42
  val%=eof
  exp%=-1
  test:

  te%=43
  val%=pos
  exp%=7
  test:
onerr e5
  REM print "testing err: 'End of file '"
  erase
  REM print "Failed to get error"
e5::
	onerr off
	if err<>-36
		REM print "Got unexpected error", err,err$(err)
		raise 5
	endif
  te%=44
  val%=count
  exp%=6
  test:

  te%=45
  val%=pos
  exp%=7
  test:


 open path$+"BENB.dbf select string1s,inti from Table1",a, s$,i%
  te%=46
  val%=count
  exp%=6
  test:

 close

trap open path$+"BENB.dbf",a,nam$,no%



REM print"Thorough Tests for LB_DBASE POS"

  trap delete path$+"POSITION.dbf"


  create path$+"POSITION.dbf",A, POS$

  te%=50
  val%=pos
  exp%=1
  test:

position -10

  te%=51
  val%=pos
  exp%=1
  test:

position 100

  te%=52
  val%=pos
  exp%=1
  test:

  c%=1
  while c%<10
     A.POS$=num$(c%,2)
     append
     te%=52+c%
     val%=pos
     exp%=c%
     test:
     c%=c%+1
  ENDWH

  c%=1
  d%=9
  while c%<10
      te%=62+c%
      first
      val%=Find(num$(d%,2))
      exp%=d%
      test:
      te%=72+c%
      val%=pos
      exp%=d%
      test:
      d%=d%-1
      c%=c%+1
  ENDWH

  c%=1
  d%=9
  first
  while c%<10
      te%=82+c%
      erase
      val%=pos
      exp%=1
      test:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -