Skip to content

Commit 4c3235f

Browse files
committed
Closed #79. Wrote tests for DataFrame>>detect:
1 parent 1b78d3a commit 4c3235f

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

src/DataFrame-Tests/DataFrameTest.class.st

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,57 @@ DataFrameTest >> testCrossTabulation [
970970
self assert: (dataFrame crossTabulate: #Gender with: #Age) equals: expected.
971971
]
972972

973+
{ #category : #tests }
974+
DataFrameTest >> testDetect [
975+
| actual expected |
976+
977+
expected := DataSeries
978+
withKeys: df columnNames
979+
values: #(London 8.788 false)
980+
name: #C.
981+
982+
actual := df detect:
983+
[ :row | (row at: #BeenThere) not ].
984+
985+
self assert: actual equals: expected.
986+
]
987+
988+
{ #category : #tests }
989+
DataFrameTest >> testDetectIfNone [
990+
| actual expected |
991+
992+
expected := DataSeries
993+
withKeys: df columnNames
994+
values: #(London 8.788 false)
995+
name: #C.
996+
997+
actual := df
998+
detect: [ :row | (row at: #BeenThere) not ]
999+
ifNone: [ 'not found' ].
1000+
1001+
self assert: actual equals: expected.
1002+
]
1003+
1004+
{ #category : #tests }
1005+
DataFrameTest >> testDetectIfNoneNotFound [
1006+
| actual expected |
1007+
1008+
expected := 'not found'.
1009+
1010+
actual := df
1011+
detect: [ :row | (row at: #City) = 'Paris' ]
1012+
ifNone: [ 'not found' ].
1013+
1014+
self assert: actual equals: expected.
1015+
]
1016+
1017+
{ #category : #tests }
1018+
DataFrameTest >> testDetectNotFound [
1019+
self
1020+
should: [ df detect: [ :row | row at: #City = 'Paris' ] ]
1021+
raise: NotFound
1022+
]
1023+
9731024
{ #category : #tests }
9741025
DataFrameTest >> testDo [
9751026

0 commit comments

Comments
 (0)