RegressionTests addPrototype: #WordCount derivedFrom: {TestCase}. "A regression test playing with license.txt" t@(RegressionTests WordCount traits) testFileName [ 'license.txt' ]. t@(RegressionTests WordCount traits) testWordCount [| words | words: Bag newEmpty. File withOpenNamed: t testFileName do: [| :file | (File ReadStream newOn: file) split >> words writer. ]. "Console ; 'Number of different words ' ; (words size as: String) ; '\n'." t assert: words size = 170 description: 'The size of the bag containing the words of licence.txt is different then what is expected'. " words sortedCounts do: [| :assoc | Console ; (assoc key as: String) ; ' - ' ; (assoc value as: String) ; '\n']. " " words elementsAndOccurencesDo: [| :elem :occ | Console ; '\'' ; (elem as: String) ; '\' ' ; (occ as: String) ; '\n' ]. " ]. t@(RegressionTests WordCount traits) testLineCount [| lineCount | lineCount: 0. File withOpenNamed: t testFileName do: [| :file | ((File ReadStream newOn: file) splitWith: { $\n }) do: [| :line | lineCount: lineCount succ]. ]. "Console ; 'Number of lines ' ; (lineCount as: String) ; '\n'." t assert: lineCount = 4 description: 'The size of the bag containing the lines of licence.txt is different then what is expected'. ]. t@(RegressionTests WordCount traits) suite [| suite | suite: TestSuite newEmpty. suite tests addAll: { t newForSelector: #testLineCount. t newForSelector: #testWordCount. }. suite ].