Updating built in Io code to use += instead of x = x + y
[io/quag.git] / libs / iovm / tests / VectorTest.io
blobeea2aa23b639ae6b1459f85e478fd754618ea9d7
1 VectorTest := UnitTest clone do(
2 testSum := method(
3 assertEquals(1+2+3+4+5, vector(1,2,3,4,5) sum)
6 testProduct := method(
7 assertEquals(1*2*3*4*5, vector(1,2,3,4,5) product)
10 testRootMeanSquare := method(
11 assertEquals((list(1,2,3,4,5) map(**2) sum / 5) sqrt, vector(1,2,3,4,5) rootMeanSquare)
14 testRemoveAt := method(
15 assertRaisesException(vector(0, 1, 2) removeAt)
16 assertRaisesException(vector(0, 1, 2) removeAt(nil))
17 assertEquals(vector(1, 2), vector(0, 1, 2) removeAt(0))
18 assertEquals(vector(0, 2), vector(0, 1, 2) removeAt(1))
19 assertEquals(vector(0, 1), vector(0, 1, 2) removeAt(2))
22 testRemoveSlice := method(
23 assertRaisesException(vector(0, 1, 2) removeSlice)
24 assertRaisesException(vector(0, 1, 2) removeSlice(nil))
25 assertRaisesException(vector(0, 1, 2) removeSlice(1, nil))
26 assertRaisesException(vector(0, 1, 2) removeSlice(nil, 2))
27 assertEquals(vector(0, 2), vector(0, 1, 2) removeSlice(1, 1))
28 assertEquals(vector(0), vector(0, 1, 2) removeSlice(1, 2))
29 assertEquals(vector(0, 1, 2), vector(0, 1, 2) removeSlice(2, 1))
30 assertEquals(vector(2), vector(0, 1, 2) asMutable removeSlice(0, 1))
31 assertEquals(vector(0, 5), vector(0, 1, 2, 3, 4, 5) removeSlice(1, 4))
32 assertEquals(vector(), vector(0, 1, 2) removeSlice(0, 2))
33 assertEquals(vector(0), vector(0, 1, 2) asMutable removeSlice(1, 8))
34 assertEquals(vector(2), vector(0, 1, 2) removeSlice(-8, 1))