class SequenceT issubclassof TestDriver functions public tests : () -> seqof TestCase
tests() ==
[ new SequenceT25(), new SequenceT23(), new SequenceT24(), new SequenceT19(), new SequenceT20(), new SequenceT21(), new SequenceT22(), new SequenceT01(), new SequenceT02(), new SequenceT03(), new SequenceT04(), new SequenceT05(), new SequenceT06(), new SequenceT07(), new SequenceT08(), new SequenceT09(), new SequenceT10(), new SequenceT11(), new SequenceT12(), new SequenceT13(), new SequenceT14(), new SequenceT15(), new SequenceT16(), new SequenceT17(), new SequenceT18()
]; end SequenceT
class SequenceT01 issubclassof TestCase operations protected test: () ==> bool
test() == let sq = new Sequence() in return (sq.Sum[int]([1,2,3,4,5,6,7,8,9]) = 45 and
sq.Sum[int]([]) = 0) and
Sequence`Product[int]([2, 3, 4]) = 24 and
Sequence`Product[int]([]) = 1
; protected setUp: () ==> ()
setUp() == TestName := "SequenceT01:\t Integer sum and product."; protected tearDown: () ==> ()
tearDown() == return; end SequenceT01
class SequenceT02 issubclassof TestCase operations protected test: () ==> bool
test() == let sq = new Sequence() in return sq.Sum[real]([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]) = 4.5 and
sq.Sum[real]([]) = 0.0 and
Sequence`Product[real]([2.0, 3.0, 4.0]) = 24.0 and
Sequence`Product[real]([]) = 1.0 and
Sequence`Product[real]([2.1, 3.2, 4.3]) = 2.1 * 3.2 * 4.3
; protected setUp: () ==> ()
setUp() == TestName := "SequenceT02:\t Real sum and product."; protected tearDown: () ==> ()
tearDown() == return; end SequenceT02
class SequenceT03 issubclassof TestCase operations protected test: () ==> bool
test() == let sq = new Sequence() in return sq.isAscendingOrder[int]([1,2,4,4,7,8,8,8]) and not sq.isAscendingOrder[real]([1.0,2.0,3.0,1.5])
; protected setUp: () ==> ()
setUp() == TestName := "SequenceT03:\t Test isAscendingOrder (integer and real)"; protected tearDown: () ==> ()
tearDown() == return; end SequenceT03
class SequenceT04 issubclassof TestCase operations protected test: () ==> bool
test() == let sq = new Sequence() in return
sq.isDescendingOrder[int]([3,2,2,1,1]) and
Sequence`isDescendingTotalOrder[int] (lambda x : int, y : int & x < y)([3,2,2,1,1]) and
Sequence`isDescendingTotalOrder[int] (lambda x : int, y : int & x < y)([3,2,2,1,2]) = false
; protected setUp: () ==> ()
setUp() == TestName := "SequenceT04:\t Test isDescendingTotalOrder (integer)."; protected tearDown: () ==> ()
tearDown() == return; end SequenceT04
class SequenceT05 issubclassof TestCase types public TestType = int|seqofchar|char; public RecordType ::
val : int
str : seqofchar
chr : char; operations public test: () ==> bool
test() == let sq = new Sequence(),
decideOrderFuncSeq =
[(lambda x : int, y : int & x < y), lambda x : seqofchar, y : seqofchar & String`LT(x,y), lambda x : char, y : char & Character`LT(x,y)
],
decideOrderFunc = lambda x : RecordType, y : RecordType &
Sequence`isOrdered[SequenceT05`TestType]
(decideOrderFuncSeq)([x.val,x.str,x.chr])([y.val,y.str,y.chr]) in return
Sequence`sort[int](lambda x : int, y : int & x < y)([3,1,5,4]) = [1,3,4,5] and
Sequence`sort[seqofchar]
(lambda x : seqofchar, y : seqofchar & String`LT(x,y))
(["12", "111", "01"]) = ["01","111","12"] and
Sequence`sort[SequenceT05`RecordType](decideOrderFunc)
([mk_RecordType(10,"sahara",'c'),mk_RecordType(10,"sahara",'a')]) =
[mk_RecordType(10,"sahara",'a'),mk_RecordType(10,"sahara",'c')] and
sq.isOrdered[SequenceT05`TestType](decideOrderFuncSeq)([3,"123",'a'])([3,"123",'A']) = trueand
sq.isOrdered[SequenceT05`TestType](decideOrderFuncSeq)([3,"123",'a'])([3,"123",'0']) = falseand
sq.isOrdered[int|seqofchar|char](decideOrderFuncSeq)([])([]) = falseand
sq.isOrdered[int|seqofchar|char](decideOrderFuncSeq)([])([3,"123",'0']) = trueand
sq.isOrdered[int|seqofchar|char](decideOrderFuncSeq)([3,"123",'0'])([]) = false
; protected setUp: () ==> ()
setUp() == TestName := "SequenceT05:\t test sort and isOrdered."; protected tearDown: () ==> ()
tearDown() == return; end SequenceT05
class SequenceT06 issubclassof TestCase operations public test: () ==> bool
test() == let sq = new Sequence(),
decideOrderFunc1 = lambda x : int, y : int & x < y,
decideOrderFunc2 = lambda x : char, y : char & Character`LT(x,y) in return
sq.Merge[int](decideOrderFunc1)([1,4,6])([2,3,4,5]) = [1,2,3,4,4,5,6] and
sq.Merge[char](decideOrderFunc2)("146")("2345") = "1234456"and
sq.Merge[char](decideOrderFunc2)("")("2345") = "2345"and
sq.Merge[char](decideOrderFunc2)("146")("") = "146"
; protected setUp: () ==> ()
setUp() == TestName := "SequenceT06:\t Merge sequences."; protected tearDown: () ==> ()
tearDown() == return; end SequenceT06
class SequenceT07 issubclassof TestCase operations public test: () ==> bool
test() == let sq = new Sequence() in return
sq.take[int](2)([2,3,4,5]) = [2,3] and
sq.drop[char](5)("Shin Sahara") = "Sahara"and
sq.last[int]([1,2,3]) = 3 and
sq.filter[int](lambda x:int & x mod 2 = 0)([1,2,3,4,5,6]) = [2,4,6] and
Sequence`SubSeq[char](4)(3)("1234567890") = "456"and
Sequence`flatten[int]([[1,2,3], [3,4], [4,5,6]]) = [ 1,2,3,3,4,4,5,6 ]
; protected setUp: () ==> ()
setUp() == TestName := "SequenceT07:\t Handling sequences."; protected tearDown: () ==> ()
tearDown() == return; end SequenceT07
class SequenceT08 issubclassof TestCase operations public test: () ==> bool
test() == return
Sequence`ascendingOrderSort[int]([3,1,6,4,2,6,5]) = [1,2,3,4,5,6,6] and
Sequence`descendingOrderSort[int]([3,1,6,4,2,6,5]) = [6,6,5,4,3,2,1]
; protected setUp: () ==> ()
setUp() == TestName := "SequenceT08:\t Test sort."; protected tearDown: () ==> ()
tearDown() == return; end SequenceT08
class SequenceT09 issubclassof TestCase operations public test: () ==> bool
test() == return
Sequence`compact[[int]]([3,1,6,4,nil,2,6,5,nil]) = [3,1,6,4,2,6,5] and
Sequence`compact[[int]]([nil,nil]) = [] and
Sequence`compact[[int]]([]) = []
; protected setUp: () ==> ()
setUp() == TestName := "SequenceT09:\t Delete nil elements."; protected tearDown: () ==> ()
tearDown() == return; end SequenceT09
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.