SilkTest学习28- anytype的陷阱 软件测试
SilkTest提供了一种可以是任何数据类型的类型anytype,如果你把一个变量申明为anytype,它的数据类型在运行时
是可以动态变化的。比如下面这个例子:
view plaincopy to clipboardprint?
01.[-] testcase anytype_var()
02. [ ] AnyType var = 10
03. [ ] Print(var)
04. [ ] var = "hello"
05. [ ] Print(var)
[-] testcase anytype_var()
[ ] AnyType var = 10
[ ] Print(var)
[ ] var = "hello"
[ ] Print(var)
但其实这个anytype并非是真正的动态变量,起码在list结构中不是这样的。当你申明一个list of anytype的列表的时
候,你无法动态改变该列表中anytype变量的类型。下面是一个例子:
view plaincopy to clipboardprint?
01.[-] testcase anytype_list_single()
02. [ ] list of ANYTYPE Row = {10, 20}
03. [ ] Print(Row[1] )
04. [ ] Row[1] = "hello"
05. [ ] Print(Row[1] )
[-] testcase anytype_list_single()
[ ] list of ANYTYPE Row = {10, 20}
[ ] Print(Row[1] )