@@ -466,6 +466,34 @@ DataSeriesTest >> testCrossTabulateWith [
466466 self assert: (series1 crossTabulateWith: series2) equals: expected.
467467]
468468
469+ { #category : #tests }
470+ DataSeriesTest >> testDetect [
471+
472+ | expected actual |
473+
474+ expected := 7 .
475+ actual := series detect: [ :x | x > 5 ].
476+ self assert: actual equals: expected.
477+ ]
478+
479+ { #category : #tests }
480+ DataSeriesTest >> testDetectIfNone [
481+
482+ | expected actual |
483+
484+ expected := ' not found' .
485+ actual := series detect: [ :x | x > 100 ] ifNone: [ ' not found' ].
486+ self assert: actual equals: expected.
487+ ]
488+
489+ { #category : #tests }
490+ DataSeriesTest >> testDetectNotFound [
491+
492+ self
493+ should: [ series detect: [ :x | x > 100 ] ]
494+ raise: NotFound .
495+ ]
496+
469497{ #category : #tests }
470498DataSeriesTest >> testDivideByScalar [
471499
@@ -687,6 +715,16 @@ DataSeriesTest >> testInequalityDifferentValues [
687715 self assert: (firstSeries ~= secondSeries).
688716]
689717
718+ { #category : #tests }
719+ DataSeriesTest >> testInjectInto [
720+
721+ | expected actual |
722+
723+ expected := 115 .
724+ actual := series inject: 0 into: [ :sum :x | sum + x ].
725+ self assert: actual equals: expected.
726+ ]
727+
690728{ #category : #tests }
691729DataSeriesTest >> testInterquartileRange [
692730
@@ -779,6 +817,20 @@ DataSeriesTest >> testRange [
779817 self assert: series range equals: 17 .
780818]
781819
820+ { #category : #tests }
821+ DataSeriesTest >> testReject [
822+
823+ | expected actual |
824+
825+ expected := DataSeries
826+ withKeys: #(a b c e f g)
827+ values: #(3 7 6 8 9 8)
828+ name: ' ExampleSeries' .
829+
830+ actual := series reject: [ :x | x >= 10 ].
831+ self assert: actual equals: expected.
832+ ]
833+
782834{ #category : #tests }
783835DataSeriesTest >> testRemoveAt [
784836
@@ -827,6 +879,20 @@ DataSeriesTest >> testSecondQuartileEqualsMedian [
827879 self assert: series secondQuartile equals: series median.
828880]
829881
882+ { #category : #tests }
883+ DataSeriesTest >> testSelect [
884+
885+ | expected actual |
886+
887+ expected := DataSeries
888+ withKeys: #(a b c e f g)
889+ values: #(3 7 6 8 9 8)
890+ name: ' ExampleSeries' .
891+
892+ actual := series select: [ :x | x < 10 ].
893+ self assert: actual equals: expected.
894+ ]
895+
830896{ #category : #tests }
831897DataSeriesTest >> testSeventh [
832898
@@ -1084,6 +1150,34 @@ DataSeriesTest >> testWithIndexCollect [
10841150 self assert: actual equals: expected.
10851151]
10861152
1153+ { #category : #tests }
1154+ DataSeriesTest >> testWithIndexDetect [
1155+
1156+ | expected actual |
1157+
1158+ expected := 6 .
1159+ actual := series withIndexDetect: [ :x :i | (x > 5 ) and : (i odd) ].
1160+ self assert: actual equals: expected.
1161+ ]
1162+
1163+ { #category : #tests }
1164+ DataSeriesTest >> testWithIndexDetectIfNone [
1165+
1166+ | expected actual |
1167+
1168+ expected := ' not found' .
1169+ actual := series withIndexDetect: [ :x :i | i > 100 ] ifNone: [ ' not found' ].
1170+ self assert: actual equals: expected.
1171+ ]
1172+
1173+ { #category : #tests }
1174+ DataSeriesTest >> testWithIndexDetectNotFound [
1175+
1176+ self
1177+ should: [ series withIndexDetect: [ :x :i | i > 100 ] ]
1178+ raise: NotFound .
1179+ ]
1180+
10871181{ #category : #tests }
10881182DataSeriesTest >> testWithIndexDo [
10891183
@@ -1096,6 +1190,34 @@ DataSeriesTest >> testWithIndexDo [
10961190 self assert: sum equals: (108173 / 4620 ).
10971191]
10981192
1193+ { #category : #tests }
1194+ DataSeriesTest >> testWithIndexReject [
1195+
1196+ | expected actual |
1197+
1198+ expected := DataSeries
1199+ withKeys: #(a c e g)
1200+ values: #(3 6 8 8)
1201+ name: ' ExampleSeries' .
1202+
1203+ actual := series withIndexReject: [ :x :i | x >= 10 or : i even ].
1204+ self assert: actual equals: expected.
1205+ ]
1206+
1207+ { #category : #tests }
1208+ DataSeriesTest >> testWithIndexSelect [
1209+
1210+ | expected actual |
1211+
1212+ expected := DataSeries
1213+ withKeys: #(a c e g)
1214+ values: #(3 6 8 8)
1215+ name: ' ExampleSeries' .
1216+
1217+ actual := series withIndexSelect: [ :x :i | x < 10 and : i odd ].
1218+ self assert: actual equals: expected.
1219+ ]
1220+
10991221{ #category : #tests }
11001222DataSeriesTest >> testWithKeyCollect [
11011223
@@ -1112,6 +1234,34 @@ DataSeriesTest >> testWithKeyCollect [
11121234 self assert: actual equals: expected.
11131235]
11141236
1237+ { #category : #tests }
1238+ DataSeriesTest >> testWithKeyDetect [
1239+
1240+ | expected actual |
1241+
1242+ expected := 6 .
1243+ actual := series withKeyDetect: [ :x :k | x > 5 and : (k = #c ) ].
1244+ self assert: actual equals: expected.
1245+ ]
1246+
1247+ { #category : #tests }
1248+ DataSeriesTest >> testWithKeyDetectIfNone [
1249+
1250+ | expected actual |
1251+
1252+ expected := ' not found' .
1253+ actual := series withKeyDetect: [ :x :k | x > 5 and : (k = #NoSuchKey ) ] ifNone: [ ' not found' ].
1254+ self assert: actual equals: expected.
1255+ ]
1256+
1257+ { #category : #tests }
1258+ DataSeriesTest >> testWithKeyDetectNotFound [
1259+
1260+ self
1261+ should: [ series withKeyDetect: [ :x :k | x > 5 and : (k = #NoSuchKey ) ] ]
1262+ raise: NotFound .
1263+ ]
1264+
11151265{ #category : #tests }
11161266DataSeriesTest >> testWithKeyDo [
11171267
@@ -1124,6 +1274,34 @@ DataSeriesTest >> testWithKeyDo [
11241274 self assert: sum equals: (108173 / 4620 ).
11251275]
11261276
1277+ { #category : #tests }
1278+ DataSeriesTest >> testWithKeyReject [
1279+
1280+ | expected actual |
1281+
1282+ expected := DataSeries
1283+ withKeys: #(a c g)
1284+ values: #(3 6 8)
1285+ name: ' ExampleSeries' .
1286+
1287+ actual := series withKeyReject: [ :x :k | x >= 10 or : (#(a c g) includes: k) not ].
1288+ self assert: actual equals: expected.
1289+ ]
1290+
1291+ { #category : #tests }
1292+ DataSeriesTest >> testWithKeySelect [
1293+
1294+ | expected actual |
1295+
1296+ expected := DataSeries
1297+ withKeys: #(a c g)
1298+ values: #(3 6 8)
1299+ name: ' ExampleSeries' .
1300+
1301+ actual := series withKeySelect: [ :x :k | x < 10 and : (#(a c g) includes: k) ].
1302+ self assert: actual equals: expected.
1303+ ]
1304+
11271305{ #category : #tests }
11281306DataSeriesTest >> testZerothQuartile [
11291307
0 commit comments