我从老师那里得到了这个测试课程,但我在理解如何实现我的课程以按此顺序创建自己时遇到了问题。
代码:
t5: BOOLEAN
local
bag: MY_BAG[STRING]
bag3: like bag2
bag4: MY_BAG[STRING]
do
comment("t5:test add_all, remove all, remove")
bag := <<["nuts", 4], ["bolts", 11], ["hammers", 5]>> -- how to implement it to allow this?
bag3 := <<["nuts", 2], ["bolts", 6], ["hammers", 5]>>
-- add_all
bag3.add_all (bag1)
Result := bag3 |=| bag
check Result end
-- remove_all
bag3.remove_all (bag1)
Result := bag3 |=| bag2 and bag3.total = 13
check Result end
--remove
bag4 := <<["nuts", 2], ["bolts", 6]>>
bag3.remove ("hammers", 5)
Result := bag3 |=| bag4
end
setup -- inherit from ES_TEST redefine setup end
-- this runs before every test
do
bag1 := <<["nuts", 2], ["bolts", 5]>>
bag2 := <<["nuts", 2], ["bolts", 6], ["hammers", 5]>>
end
目前,当我使用此类测试用例进行编译时,它会引发编译器错误,提示创建不正确、不兼容
我的构造函数目前制作了一个空的 HASH_TABLE 所以我的问题是如何确保我可以按照代码测试的方式初始化我的包类?