SystemOrganization addCategory: #'TextLint-Tests'! SystemOrganization addCategory: #'TextLint-Model'! TestCase subclass: #TLALotRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLALotRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/6/2010 10:53'! testFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'A')). words add: (TLWord with: (PPToken on: 'lot')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLALotRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLALotRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/6/2010 10:54'! testFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'a')). words add: (TLWord with: (PPToken on: 'Lot')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLALotRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLALotRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/6/2010 10:54'! testSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'lot')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLTheFactThatRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! TestCase subclass: #TLAllowToRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:29'! testAllowToFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results| words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'Allow')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAllowToRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:29'! testAllowToFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'Allow')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAllowToRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:36'! testAllowToSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'allow')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAllowToRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:30'! testAllowsToFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'Allows')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAllowToRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:30'! testAllowsToFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'Allows')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAllowToRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:36'! testAllowsToSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'allows')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAllowToRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! TestCase subclass: #TLAsToWhetherRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLAsToWhetherRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:36'! testFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'As')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWord with: (PPToken on: 'whether')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAsToWhetherRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLAsToWhetherRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:37'! testFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'as')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWord with: (PPToken on: 'Whether')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAsToWhetherRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLAsToWhetherRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:37'! testSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWord with: (PPToken on: 'whether')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAsToWhetherRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! TestCase subclass: #TLAvoidQuilifiersRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLAvoidQuilifiersRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:37'! testCaseInsensitive | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | aWord := TLWord with: (PPToken on: 'Rather'). anotherWord := TLWord with: (PPToken on: 'test'). words := OrderedCollection with: aWord with: anotherWord. aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAvoidQualifiersRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLAvoidQuilifiersRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:37'! testLittleFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | aWord := TLWord with: (PPToken on: 'little'). anotherWord := TLWord with: (PPToken on: 'test'). words := OrderedCollection with: aWord with: anotherWord. aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAvoidQualifiersRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLAvoidQuilifiersRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:37'! testPrettyFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | aWord := TLWord with: (PPToken on: 'pretty'). anotherWord := TLWord with: (PPToken on: 'test'). words := OrderedCollection with: aWord with: anotherWord. aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAvoidQualifiersRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLAvoidQuilifiersRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:37'! testQuiteFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | aWord := TLWord with: (PPToken on: 'quite'). anotherWord := TLWord with: (PPToken on: 'test'). words := OrderedCollection with: aWord with: anotherWord. aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAvoidQualifiersRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLAvoidQuilifiersRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:38'! testRatherFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | aWord := TLWord with: (PPToken on: 'rather'). anotherWord := TLWord with: (PPToken on: 'test'). words := OrderedCollection with: aWord with: anotherWord. aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAvoidQualifiersRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLAvoidQuilifiersRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:38'! testSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | aWord := TLWord with: (PPToken on: 'test'). anotherWord := TLWord with: (PPToken on: 'test'). words := OrderedCollection with: aWord with: anotherWord. aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAvoidQualifiersRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! !TLAvoidQuilifiersRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:38'! testVeryFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | aWord := TLWord with: (PPToken on: 'very'). anotherWord := TLWord with: (PPToken on: 'test'). words := OrderedCollection with: aWord with: anotherWord. aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLAvoidQualifiersRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! TestCase subclass: #TLDocumentTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLDocumentTest methodsFor: 'test' stamp: 'JorgeRessia 4/4/2010 13:38'! testCreation | aDocument | aDocument := TLDocument withAll: 1. self assert: aDocument paragraphs = 1! ! !TLDocumentTest methodsFor: 'test' stamp: 'JorgeRessia 4/4/2010 13:40'! testSentences | aDocument words aSentence aParagraph sentences paragraphs| words := OrderedCollection new. words add: (TLWord with: (PPToken on: '1')). words add: (TLWord with: (PPToken on: '2')). words add: (TLWord with: (PPToken on: '3')). words add: (TLWord with: (PPToken on: '4')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. self assert: aDocument sentences size = 1. self assert: aDocument sentences first = aSentence! ! !TLDocumentTest methodsFor: 'test' stamp: 'JorgeRessia 4/4/2010 13:44'! testWords | aDocument words aSentence aParagraph sentences paragraphs| words := OrderedCollection new. words add: (TLWord with: (PPToken on: '1')). words add: (TLWord with: (PPToken on: '2')). words add: (TLWord with: (PPToken on: '3')). words add: (TLWord with: (PPToken on: '4')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. self assert: aDocument words size = 4. self assert: ( (aDocument words asArray at: 1) text = '1' ). self assert: ( (aDocument words asArray at: 2) text = '2' ). self assert: ( (aDocument words asArray at: 3) text = '3' ). self assert: ( (aDocument words asArray at: 4) text = '4' ).! ! TestCase subclass: #TLHelpToRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:38'! testHelpToFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'Help')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLHelpToRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:38'! testHelpToFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'Help')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLHelpToRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:38'! testHelpToSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'help')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLHelpToRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:39'! testHelpsToFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'Helps')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLHelpToRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:39'! testHelpsToFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'Helps')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLHelpToRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:39'! testHelpsToSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'helps')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLHelpToRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! TestCase subclass: #TLHoweverRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLHoweverRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:39'! testFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | aWord := TLWord with: (PPToken on: 'However'). anotherWord := TLWord with: (PPToken on: 'test'). words := OrderedCollection with: aWord with: anotherWord. aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLHoweverRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLHoweverRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:39'! testSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | aWord := TLWord with: (PPToken on: 'test'). anotherWord := TLWord with: (PPToken on: 'test'). words := OrderedCollection with: aWord with: anotherWord. aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLHoweverRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! TestCase subclass: #TLOneOfTheMostRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLOneOfTheMostRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:40'! testFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'One')). words add: (TLWord with: (PPToken on: 'of')). words add: (TLWord with: (PPToken on: 'the')). words add: (TLWord with: (PPToken on: 'most')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLOneOfTheMostRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLOneOfTheMostRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:40'! testSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'A')). words add: (TLWord with: (PPToken on: 'of')). words add: (TLWord with: (PPToken on: 'the')). words add: (TLWord with: (PPToken on: 'most')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLOneOfTheMostRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! TestCase subclass: #TLParagraphTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLParagraphTest methodsFor: 'test' stamp: 'JorgeRessia 4/4/2010 13:22'! testCreation | aParagraph | aParagraph := TLParagraph withAll: 1. self assert: aParagraph sentences = 1! ! TestCase subclass: #TLRegardedAsBeingRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLRegardedAsBeingRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:40'! testFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'Regarded')). words add: (TLWord with: (PPToken on: 'as')). words add: (TLWord with: (PPToken on: 'being')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLRegardedAsBeingRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLRegardedAsBeingRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:40'! testFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'Regarded')). words add: (TLWord with: (PPToken on: 'as')). words add: (TLWord with: (PPToken on: 'being')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLRegardedAsBeingRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLRegardedAsBeingRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:40'! testSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'as')). words add: (TLWord with: (PPToken on: 'being')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLRegardedAsBeingRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! TestCase subclass: #TLRequireToRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:41'! testRequireToFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'Require')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLRequireToRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:41'! testRequireToFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'Require')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLRequireToRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:41'! testRequireToSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'require')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLRequireToRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:41'! testRequiresToFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'Requires')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLRequireToRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:42'! testRequiresToFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'Requires')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLRequireToRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:42'! testRequiresToSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'resquires')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLRequireToRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! TestCase subclass: #TLRulesArquitechtureTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLRulesArquitechtureTest methodsFor: 'test' stamp: 'JorgeRessia 4/2/2010 17:54'! testRationale TLTextLintRule allSubclassesDo: [ :aClass | aClass new rationale size > 10]. ! ! TestCase subclass: #TLSentenceTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLSentenceTest class methodsFor: 'accessing' stamp: 'lr 4/5/2010 00:55'! packageNamesUnderTest ^ #('TextLint-Tests')! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/2/2010 08:42'! testContainsPhraseAtTheBeginning | aSentence words| words := OrderedCollection new. words add: (TLWord with: (PPToken on: '1')). words add: (TLWord with: (PPToken on: '2')). words add: (TLWord with: (PPToken on: '3')). words add: (TLWord with: (PPToken on: 'xxxx')). aSentence := TLSentence withAll: words. self assert: (aSentence containsPhrase: '1 2 3')! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/2/2010 08:57'! testContainsPhraseAtTheEnd | aSentence words| words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'xxxx')). words add: (TLWord with: (PPToken on: '1')). words add: (TLWord with: (PPToken on: '2')). words add: (TLWord with: (PPToken on: '3')). aSentence := TLSentence withAll: words. self assert: (aSentence containsPhrase: '1 2 3')! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/2/2010 08:56'! testContainsPhraseAtTheMiddle | aSentence words| words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'xxxx')). words add: (TLWord with: (PPToken on: '1')). words add: (TLWord with: (PPToken on: '2')). words add: (TLWord with: (PPToken on: '3')). words add: (TLWord with: (PPToken on: 'xxxx')). aSentence := TLSentence withAll: words. self assert: (aSentence containsPhrase: '1 2 3')! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/2/2010 08:58'! testContainsPhraseInAnyCase | aSentence words| words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'xxxx')). words add: (TLWord with: (PPToken on: 'a')). words add: (TLWord with: (PPToken on: 'b')). words add: (TLWord with: (PPToken on: 'c')). aSentence := TLSentence withAll: words. self assert: (aSentence containsPhrase: 'A B C'). words add: (TLWord with: (PPToken on: 'xxxx')). words add: (TLWord with: (PPToken on: 'a')). words add: (TLWord with: (PPToken on: 'b')). words add: (TLWord with: (PPToken on: 'c')). aSentence := TLSentence withAll: words. self assert: (aSentence containsPhrase: 'a b c'). words add: (TLWord with: (PPToken on: 'xxxx')). words add: (TLWord with: (PPToken on: 'a')). words add: (TLWord with: (PPToken on: 'B')). words add: (TLWord with: (PPToken on: 'c')). aSentence := TLSentence withAll: words. self assert: (aSentence containsPhrase: 'A B c')! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/4/2010 13:12'! testCreation | aSentence | aSentence := TLSentence withAll: 1. self assert: aSentence words = 1! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/4/2010 13:16'! testWordsAsString | aSentence words| words := OrderedCollection new. words add: (TLWord with: (PPToken on: '1')). words add: (TLWord with: (PPToken on: '2')). aSentence := TLSentence withAll: words. self assert: aSentence wordsAsString = ' 1 2'! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/6/2010 12:03'! testWordsAsStringRealText | aSentence words| words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'a')). words add: (TLWord with: (PPToken on: 'lot')). words add: (TLWord with: (PPToken on: 'that')). aSentence := TLSentence withAll: words. self assert: aSentence wordsAsString = ' test a lot that'! ! TestCase subclass: #TLTextLintCheckerTest instanceVariableNames: 'result' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLTextLintCheckerTest methodsFor: 'test' stamp: 'JorgeRessia 4/6/2010 12:19'! testCheckSingleRule | aChecker | result := OrderedCollection new. aChecker := TLTextLintChecker new. aChecker addRule: (TLALotRule new). aChecker check: 'test a lot that.'. self assert: ( aChecker results size = 1 ). self assert: ( aChecker results first wordsAsString = ' test a lot that' ) ! ! TestCase subclass: #TLTextLintRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLTextLintRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/1/2010 12:10'! test | aRule | aRule := TLTextLintRule new. aRule check: 1. self assert: true.! ! TestCase subclass: #TLTextParserTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLTextParserTest methodsFor: 'test' stamp: 'JorgeRessia 4/6/2010 15:07'! testSimple | aParser aDocument | aParser := TLTextParser new. aDocument := aParser parse: 'text1 text2.'. self deny: aDocument isPetitFailure. self assert: aDocument paragraphs size = 1. self assert: aDocument sentences size = 1. self assert: aDocument words size = 2. self assert: aDocument words first token value = 'text1'. self assert: aDocument words last token value = 'text2'.! ! !TLTextParserTest methodsFor: 'test' stamp: 'JorgeRessia 4/6/2010 15:10'! testTextWithPunctuationMarks | aParser aDocument | aParser := TLTextParser new. aDocument := aParser parse: 'text1, hal !! text2. '. self deny: aDocument isPetitFailure. self assert: aDocument paragraphs size = 1. self assert: aDocument sentences size = 3. self assert: aDocument words size = 3. self assert: aDocument words first token value = 'text1'. self assert: aDocument words second token value = 'hal'. self assert: aDocument words last token value = 'text2'.! ! TestCase subclass: #TLTheFactIsRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLTheFactIsRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:42'! testFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'The')). words add: (TLWord with: (PPToken on: 'fact')). words add: (TLWord with: (PPToken on: 'is')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLTheFactIsRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLTheFactIsRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:42'! testFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'The')). words add: (TLWord with: (PPToken on: 'fact')). words add: (TLWord with: (PPToken on: 'is')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLTheFactIsRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLTheFactIsRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:42'! testSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'fact')). words add: (TLWord with: (PPToken on: 'is')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLTheFactIsRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! TestCase subclass: #TLTheFactThatRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLTheFactThatRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:45'! testFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'The')). words add: (TLWord with: (PPToken on: 'fact')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLTheFactThatRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLTheFactThatRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:45'! testFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'The')). words add: (TLWord with: (PPToken on: 'fact')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLTheFactThatRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLTheFactThatRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:46'! testSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'fact')). words add: (TLWord with: (PPToken on: 'that')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLTheFactThatRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! TestCase subclass: #TLTheTruthIsRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLTheTruthIsRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:46'! testFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'The')). words add: (TLWord with: (PPToken on: 'truth')). words add: (TLWord with: (PPToken on: 'is')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLTheTruthIsRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLTheTruthIsRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:46'! testFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'The')). words add: (TLWord with: (PPToken on: 'truth')). words add: (TLWord with: (PPToken on: 'is')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLTheTruthIsRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLTheTruthIsRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:46'! testSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'truth')). words add: (TLWord with: (PPToken on: 'is')). words add: (TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLTheTruthIsRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! TestCase subclass: #TLWordRepetitionRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLWordRepetitionRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:46'! testFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | aWord := TLWord with: (PPToken on: 'test'). anotherWord := TLWord with: (PPToken on: 'test'). words := OrderedCollection with: aWord with: anotherWord. aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLWordRepetitionRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLWordRepetitionRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/6/2010 09:22'! testFailureCaseInsensitive | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | aWord := TLWord with: (PPToken on: 'Test'). anotherWord := TLWord with: (PPToken on: 'test'). words := OrderedCollection with: aWord with: anotherWord. aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLWordRepetitionRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLWordRepetitionRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:46'! testFailureManyWords | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'tes')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'xxxx')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLWordRepetitionRule new. results := aRule runOn: aDocument. self assert: results size = 1. ! ! !TLWordRepetitionRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:46'! testFailureThreeInRow | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'xxxx')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLWordRepetitionRule new. results := aRule runOn: aDocument. self assert: results size = 2. ! ! !TLWordRepetitionRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/5/2010 10:46'! testSuccess | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | aWord := TLWord with: (PPToken on: 'test1'). anotherWord := TLWord with: (PPToken on: 'test'). words := OrderedCollection with: aWord with: anotherWord. aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLWordRepetitionRule new. results := aRule runOn: aDocument. self assert: results size = 0. ! ! TestCase subclass: #TLWordTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLWordTest methodsFor: 'test' stamp: 'JorgeRessia 4/4/2010 13:09'! testCreation | aWord | aWord := TLWord with: 1. self assert: aWord token = 1! ! !TLWordTest methodsFor: 'test' stamp: 'JorgeRessia 4/4/2010 13:10'! testText | aWord | aWord := TLWord with: (PPToken on: '1') . self assert: aWord text = '1'! ! PPCompositeParser subclass: #TLTextChecker instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! PPCompositeParser subclass: #TLTextParser instanceVariableNames: 'document paragraph sentence word' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLTextParser methodsFor: 'productions' stamp: 'lr 3/31/2010 11:27'! document ^ (paragraph delimitedBy: #newline asParser token) ==> [ :nodes | TLDocument withAll: (nodes reject: [ :each | each class = PPToken ]) ]! ! !TLTextParser methodsFor: 'productions' stamp: 'JorgeRessia 4/6/2010 15:07'! paragraph ^ (sentence delimitedBy: #word asParser negate plus token) ==> [ :nodes | TLParagraph withAll: (nodes reject: [ :each | each class = PPToken ]) ]! ! !TLTextParser methodsFor: 'productions' stamp: 'lr 3/31/2010 11:29'! sentence ^ word plus ==> [ :nodes | TLSentence withAll: nodes ]! ! !TLTextParser methodsFor: 'accessing' stamp: 'lr 3/31/2010 10:59'! start ^ document end! ! !TLTextParser methodsFor: 'productions' stamp: 'JorgeRessia 4/6/2010 12:17'! word ^ #word asParser plus token ==> [ :node | TLWord with: node ]! ! Object subclass: #TLDocument instanceVariableNames: 'paragraphs' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLDocument class methodsFor: 'instance creation' stamp: 'lr 3/31/2010 11:15'! withAll: aCollection ^self new initializeWithAll: aCollection! ! !TLDocument methodsFor: 'initialization' stamp: 'lr 3/31/2010 11:16'! initializeWithAll: aCollection paragraphs := aCollection! ! !TLDocument methodsFor: 'accessing' stamp: 'lr 3/31/2010 11:22'! paragraphs ^paragraphs ! ! !TLDocument methodsFor: 'accessing' stamp: 'lr 3/31/2010 11:24'! sentences ^ self paragraphs gather: [ :each | each sentences ]! ! !TLDocument methodsFor: 'accessing' stamp: 'lr 3/31/2010 11:24'! words ^self sentences gather: [ :each | each words ]! ! Object subclass: #TLParagraph instanceVariableNames: 'sentences' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLParagraph class methodsFor: 'instance creation' stamp: 'lr 3/31/2010 11:16'! withAll: aCollection ^self new initializeWithAll: aCollection! ! !TLParagraph methodsFor: 'initialization' stamp: 'lr 3/31/2010 11:17'! initializeWithAll: aCollection sentences := aCollection! ! !TLParagraph methodsFor: 'accessing' stamp: 'lr 3/31/2010 11:32'! sentences ^sentences! ! Object subclass: #TLSentence instanceVariableNames: 'words' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLSentence class methodsFor: 'instance creation' stamp: 'lr 3/31/2010 11:17'! withAll: aCollection ^self new initializeWithAll: aCollection! ! !TLSentence methodsFor: 'testing' stamp: 'lr 4/5/2010 10:25'! containsPhrase: aString ^ self wordsAsString includesSubstring: aString caseSensitive: false! ! !TLSentence methodsFor: 'initialization' stamp: 'lr 3/31/2010 11:17'! initializeWithAll: aCollection words := aCollection! ! !TLSentence methodsFor: 'accessing' stamp: 'lr 3/31/2010 11:20'! words ^ words! ! !TLSentence methodsFor: 'accessing' stamp: 'JorgeRessia 4/6/2010 12:19'! wordsAsString ^words inject: '' into: [:count :each | count, ' ', each token value] ! ! Object subclass: #TLTextLintChecker instanceVariableNames: 'rules results' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLTextLintChecker methodsFor: 'accessing' stamp: 'JorgeRessia 3/31/2010 16:49'! addRule: aRule rules add: aRule! ! !TLTextLintChecker methodsFor: 'public' stamp: 'JorgeRessia 3/31/2010 16:55'! check: aString | aDocument | aDocument := TLTextParser parse: aString. self checkDocument: aDocument.! ! !TLTextLintChecker methodsFor: 'mocking' stamp: 'JorgeRessia 4/6/2010 11:49'! checkDocument: aDocument results := rules gather: [ :each | each runOn: aDocument]! ! !TLTextLintChecker methodsFor: 'initializing' stamp: 'JorgeRessia 3/31/2010 16:50'! initialize rules := OrderedCollection new! ! !TLTextLintChecker methodsFor: 'accessing' stamp: 'JorgeRessia 4/6/2010 11:36'! results ^results! ! Object subclass: #TLTextLintRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! TLTextLintRule subclass: #TLALotRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLALotRule methodsFor: 'accessing' stamp: 'JorgeRessia 4/6/2010 10:51'! rationale ^ 'Avoid using a lot, it weakens the sentence'! ! !TLALotRule methodsFor: 'running' stamp: 'JorgeRessia 4/6/2010 10:52'! runOn: aDocument | results | results := OrderedCollection new. aDocument sentences do: [:eachSentence | (eachSentence containsPhrase: 'a lot') ifTrue: [ results add: eachSentence] ]. ^results ! ! TLTextLintRule subclass: #TLAllowToRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLAllowToRule methodsFor: 'accessing' stamp: 'JorgeRessia 4/4/2010 10:19'! rationale ^ 'Never use the expressions "allow/s to". This expression requires a direct object.'! ! !TLAllowToRule methodsFor: 'running' stamp: 'JorgeRessia 4/5/2010 10:50'! runOn: aDocument | results | results := OrderedCollection new. aDocument sentences do: [:eachSentence | ((eachSentence containsPhrase: 'allow to') or: [eachSentence containsPhrase: 'allows to']) ifTrue: [ results add: eachSentence] ]. ^ results. ! ! TLTextLintRule subclass: #TLAsToWhetherRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLAsToWhetherRule methodsFor: 'accessing' stamp: 'JorgeRessia 4/2/2010 18:01'! rationale ^ 'Words and expressions commonly missused - as to whether -> it is enough with whether'! ! !TLAsToWhetherRule methodsFor: 'running' stamp: 'JorgeRessia 4/5/2010 10:50'! runOn: aDocument | results | results := OrderedCollection new. aDocument sentences do: [:eachSentence | (eachSentence containsPhrase: 'as to whether') ifTrue: [ results add: eachSentence] ]. ^results ! ! TLTextLintRule subclass: #TLAvoidQualifiersRule instanceVariableNames: 'qualifiers' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLAvoidQualifiersRule methodsFor: 'initialization' stamp: 'lr 4/5/2010 00:54'! initialize super initialize. self initializeQuilifiers.! ! !TLAvoidQualifiersRule methodsFor: 'initialization' stamp: 'JorgeRessia 4/6/2010 10:50'! initializeQuilifiers qualifiers := OrderedCollection new. qualifiers add: 'rather'; add: 'very'; add: 'pretty'; add: 'little'; add: 'quite'. ! ! !TLAvoidQualifiersRule methodsFor: 'accessing' stamp: 'JorgeRessia 4/2/2010 18:10'! rationale ^ 'Avoid the use of qualifiers. These are the leeches that infest the pond of prose, sucking the blood of words. The constant use of the adjective little (except to indicate size) is particularly debilitating; we should all try to do a little better, we should all be very watchful of this rule, for it is a rather important one, and we are pretty sure to violate it now and then. Rule 8, An approach to Style - The Elements of Style - W. Strunk and E.B. White'! ! !TLAvoidQualifiersRule methodsFor: 'running' stamp: 'JorgeRessia 4/5/2010 10:50'! runOn: aDocument | results | results := OrderedCollection new. aDocument words do: [:eachWord | ( qualifiers includes: eachWord text translateToLowercase ) ifTrue: [ results add: eachWord]]. ^results ! ! TLTextLintRule subclass: #TLHelpToRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLHelpToRule methodsFor: 'accessing' stamp: 'JorgeRessia 4/4/2010 10:41'! rationale ^ 'Never use the expressions "help/s to". This expression requires a direct object.'! ! !TLHelpToRule methodsFor: 'running' stamp: 'JorgeRessia 4/5/2010 10:50'! runOn: aDocument | results | results := OrderedCollection new. aDocument sentences do: [:eachSentence | ((eachSentence containsPhrase: 'help to') or: [eachSentence containsPhrase: 'helps to']) ifTrue: [ results add: eachSentence] ]. ^results ! ! TLTextLintRule subclass: #TLHoweverRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLHoweverRule methodsFor: 'accessing' stamp: 'JorgeRessia 4/2/2010 18:13'! rationale ^ 'Avoid starting a sentence with however when the meaning is nevertheless. The word usually serves when not in first possition. Misused words and expressions (page 48) - The Elements of Style - W. Strunk and E.B. White'! ! !TLHoweverRule methodsFor: 'running' stamp: 'JorgeRessia 4/5/2010 10:50'! runOn: aDocument | results | results := OrderedCollection new. aDocument sentences do: [:eachSentence | (eachSentence words first text = 'However') ifTrue: [ results add: eachSentence] ]. ^results ! ! TLTextLintRule subclass: #TLOneOfTheMostRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLOneOfTheMostRule methodsFor: 'accessing' stamp: 'JorgeRessia 4/2/2010 18:16'! rationale ^ 'Avoid this feeble formula. There is nothing wrong with the grammar the formula is simple threadbare. Misused words and expressions (page 55) - The Elements of Style - W. Strunk and E.B. White'! ! !TLOneOfTheMostRule methodsFor: 'running' stamp: 'JorgeRessia 4/5/2010 10:50'! runOn: aDocument | results | results := OrderedCollection new. aDocument sentences do: [:eachSentence | (eachSentence containsPhrase: 'one of the most') ifTrue: [ results add: eachSentence] ]. ^results. ! ! TLTextLintRule subclass: #TLRegardedAsBeingRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLRegardedAsBeingRule methodsFor: 'accessing' stamp: 'JorgeRessia 4/2/2010 18:19'! rationale ^ 'Being is not appropriate after regard...as. Misused words and expressions (page 41) - The Elements of Style - W. Strunk and E.B. White'! ! !TLRegardedAsBeingRule methodsFor: 'running' stamp: 'JorgeRessia 4/5/2010 10:50'! runOn: aDocument | results | results := OrderedCollection new. aDocument sentences do: [:eachSentence | (eachSentence containsPhrase: 'regarded as being') ifTrue: [ results add: eachSentence] ]. ^results ! ! TLTextLintRule subclass: #TLRequireToRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLRequireToRule methodsFor: 'accessing' stamp: 'JorgeRessia 4/4/2010 10:25'! rationale ^ 'Never use the expressions "require/s to". This expression requires a direct object.'! ! !TLRequireToRule methodsFor: 'running' stamp: 'JorgeRessia 4/5/2010 10:50'! runOn: aDocument | results | results := OrderedCollection new. aDocument sentences do: [:eachSentence | ((eachSentence containsPhrase: 'require to') or: [eachSentence containsPhrase: 'requires to']) ifTrue: [ results add: eachSentence] ]. ^results ! ! !TLTextLintRule methodsFor: 'public' stamp: 'JorgeRessia 4/1/2010 12:10'! check: anObject ! ! !TLTextLintRule methodsFor: 'accessing' stamp: 'JorgeRessia 4/2/2010 17:44'! rationale ^ self subclassResponsibility! ! !TLTextLintRule methodsFor: 'running' stamp: 'JorgeRessia 4/5/2010 10:29'! runOn: aDocument ^self subclassResponsibility! ! TLTextLintRule subclass: #TLTheFactIsRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLTheFactIsRule methodsFor: 'accessing' stamp: 'JorgeRessia 4/2/2010 18:30'! rationale ^ 'A bad beginning for a sentence. If you think you are possessed of the truth or fact state it. Principles of composition (page 60) - The Elements of Style - W. Strunk and E.B. White'! ! !TLTheFactIsRule methodsFor: 'running' stamp: 'JorgeRessia 4/5/2010 10:51'! runOn: aDocument | results | results := OrderedCollection new. aDocument sentences do: [:eachSentence | (eachSentence containsPhrase: 'the fact is') ifTrue: [ results add: eachSentence] ]. ^results ! ! TLTextLintRule subclass: #TLTheFactThatRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLTheFactThatRule methodsFor: 'accessing' stamp: 'JorgeRessia 4/2/2010 18:21'! rationale ^ 'The fact that is an especially debilitating expression. Principles of composition (page 24) - The Elements of Style - W. Strunk and E.B. White'! ! !TLTheFactThatRule methodsFor: 'running' stamp: 'JorgeRessia 4/5/2010 10:51'! runOn: aDocument | results | results := OrderedCollection new. aDocument sentences do: [:eachSentence | (eachSentence containsPhrase: 'the fact that') ifTrue: [ results add: eachSentence] ]. ^results ! ! TLTextLintRule subclass: #TLTheTruthIsRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLTheTruthIsRule methodsFor: 'accessing' stamp: 'JorgeRessia 4/2/2010 18:30'! rationale ^ 'A bad beginning for a sentence. If you think you are possessed of the truth or fact state it. Principles of composition (page 60) - The Elements of Style - W. Strunk and E.B. White'! ! !TLTheTruthIsRule methodsFor: 'running' stamp: 'JorgeRessia 4/5/2010 10:51'! runOn: aDocument | results | results := OrderedCollection new. aDocument sentences do: [:eachSentence | (eachSentence containsPhrase: 'the truth is') ifTrue: [ results add: eachSentence] ]. ^results ! ! TLTextLintRule subclass: #TLWordRepetitionRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLWordRepetitionRule methodsFor: 'accessing' stamp: 'JorgeRessia 4/2/2010 18:22'! rationale ^ 'Detection of words repetion'! ! !TLWordRepetitionRule methodsFor: 'running' stamp: 'JorgeRessia 4/6/2010 09:24'! runOn: aDocument | words results | results := OrderedCollection new. aDocument sentences do: [:eachSentence | words := eachSentence words asArray. (words size < 2) ifTrue: [^self]. 2 to: words size do: [:index | ((words at: index) text translateToLowercase = (words at: index - 1) text translateToLowercase) ifTrue: [ results add: eachSentence] ] ]. ^results ! ! Object subclass: #TLWord instanceVariableNames: 'token' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLWord class methodsFor: 'instance creation' stamp: 'JorgeRessia 4/6/2010 12:18'! with: aToken ^self new initializeWith: aToken! ! !TLWord methodsFor: 'initialization' stamp: 'lr 3/31/2010 11:18'! initializeWith: aToken token := aToken! ! !TLWord methodsFor: 'accessing' stamp: 'JorgeRessia 4/1/2010 15:14'! text ^token collection! ! !TLWord methodsFor: 'accessing' stamp: 'lr 3/31/2010 11:21'! token ^ token! !