SystemOrganization addCategory: #'TextLint-Model'! SystemOrganization addCategory: #'TextLint-Model-Tests'! SystemOrganization addCategory: #'TextLint-Parser'! SystemOrganization addCategory: #'TextLint-Parser-Tests'! SystemOrganization addCategory: #'TextLint-Runner'! SystemOrganization addCategory: #'TextLint-Runner-Tests'! SystemOrganization addCategory: #'TextLint-Rules'! SystemOrganization addCategory: #'TextLint-Rules-Tests'! SystemOrganization addCategory: #'TextLint-Wizard'! WizardControl subclass: #TLTestGUI instanceVariableNames: 'progBar mooseModel' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Wizard'! !TLTestGUI methodsFor: 'as yet unclassified' stamp: 'FabrizioPerin 4/7/2010 16:29'! actionsToPerform | sourcePathName mseFilePathName checkBoxesSelected | sourcePathName := wizardInformations at: #sourceDirectoryPath. mseFilePathName := wizardInformations at: #mseFilePathName. checkBoxesSelected := wizardInformations at: #openBrowsers. sourcePathName inspect. mseFilePathName inspect. checkBoxesSelected inspect. ! ! !TLTestGUI methodsFor: 'as yet unclassified' stamp: 'FabrizioPerin 4/7/2010 17:01'! buildWizardPanels | pane1 pane2 part1 part2 part3 part4 part5 | pane1 := WizardFirstPane named: 'Select the Latex file to check'. pane2 := WizardLastPane named: 'Select the Ruels to use'. part1 := TLChooseFilePart new. pane1 addPart: part1 associatedTo: #sourceDirectoryPath. part2 := TLMultiCheckboxesPart groupName: 'BARBAs RULZ' withAll: (OrderedCollection with: 'RULEZ1' with: 'RULEZ2' with: 'RULEZ3'). pane2 addPart: part2 associatedTo: #openBrowsers. part3 := TLMultiCheckboxesPart groupName: 'BARBAs RULZ 2' withAll: (OrderedCollection with: 'RULEZ4' with: 'RULEZ5' with: 'RULEZ6'). pane2 addPart: part3 associatedTo: #openBrowsers. part4 := TLMultiCheckboxesPart groupName: 'BARBAs RULZ 3' withAll: (OrderedCollection with: 'RULEZ4' with: 'RULEZ5' with: 'RULEZ6'). pane2 addRightPart: part4 associatedTo: #openBrowsers. part5 := TLMultiCheckboxesPart groupName: 'BARBAs RULZ 4' withAll: (OrderedCollection with: 'RULEZ4' with: 'RULEZ5' with: 'RULEZ6'). pane2 addPart: part5 associatedTo: #openBrowsers. self addPane: pane1. self addPane: pane2. ! ! !TLTestGUI methodsFor: 'initialization' stamp: 'FabrizioPerin 4/7/2010 16:54'! initialize super initialize. self buildWizardPanels. ! ! !TLTestGUI methodsFor: 'as yet unclassified' stamp: 'FabrizioPerin 4/7/2010 14:55'! performTerminateButtonAction "by default, just close the last current pane. Override this method if you want to create a subclass of WizardControl making a specific action" "^self subclassResponsibility" UIManager default displayProgress: 'Processing' at: Sensor cursorPoint from: 1 to: 10 during: [ :bar | progBar := bar. progBar value: 2. super performTerminateButtonAction . self actionsToPerform.].! ! TestCase subclass: #TLALotRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules-Tests'! !TLALotRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:52'! 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. self assert: results first = aSentence. ! ! !TLALotRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22: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. self assert: results first = aSentence. ! ! !TLALotRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 11: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 isEmpty. ! ! TestCase subclass: #TLAllowToRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules-Tests'! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:54'! 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. self assert: results first = aSentence. ! ! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:54'! 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. self assert: results first = aSentence. ! ! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 11:54'! 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 isEmpty! ! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:54'! 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. self assert: results first = aSentence. ! ! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:54'! 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. self assert: results first = aSentence. ! ! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 11:55'! 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 isEmpty! ! TestCase subclass: #TLAsToWhetherRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules-Tests'! !TLAsToWhetherRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:55'! 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. self assert: results first = aSentence. ! ! !TLAsToWhetherRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:55'! 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. self assert: results first = aSentence. ! ! !TLAsToWhetherRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 11:55'! 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 isEmpty! ! TestCase subclass: #TLAvoidQualifiersRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules-Tests'! !TLAvoidQualifiersRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:56'! 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. self assert: results first = aWord. ! ! !TLAvoidQualifiersRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:56'! 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. self assert: results first = aWord. ! ! !TLAvoidQualifiersRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:56'! 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. self assert: results first = aWord. ! ! !TLAvoidQualifiersRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:56'! 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. self assert: results first = aWord. ! ! !TLAvoidQualifiersRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:56'! 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. self assert: results first = aWord. ! ! !TLAvoidQualifiersRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 11:56'! 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 isEmpty! ! !TLAvoidQualifiersRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:56'! 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. self assert: results first = aWord. ! ! TestCase subclass: #TLDocumentTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model-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/7/2010 12:16'! testIsDocument | aDocument | aDocument := TLDocument withAll: 1. self assert: aDocument isDocument. self deny: aDocument isParagraph. self deny: aDocument isSentence. self deny: aDocument isWord. self deny: aDocument isPunctuation. self deny: aDocument isEndOfDocument. self deny: aDocument isWhitespace.! ! !TLDocumentTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 11:56'! 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/7/2010 11:57'! 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-Rules-Tests'! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:57'! 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. self assert: results first = aSentence. ! ! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:57'! 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. self assert: results first = aSentence. ! ! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 11:57'! 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 isEmpty! ! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:57'! 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 first = aSentence. self assert: results size = 1. ! ! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:57'! 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. self assert: results first = aSentence. ! ! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 11:58'! 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 isEmpty! ! TestCase subclass: #TLHoweverRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules-Tests'! !TLHoweverRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 12:17'! 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. self assert: results first = aWord. ! ! !TLHoweverRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 12:18'! testFailureCaseInsensitive | 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. self assert: results first = aWord. ! ! !TLHoweverRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 11:58'! 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 isEmpty! ! TestCase subclass: #TLOneOfTheMostRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules-Tests'! !TLOneOfTheMostRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:58'! 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. self assert: results first = aSentence. ! ! !TLOneOfTheMostRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:59'! testFailureInSentence | 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: '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. self assert: results first = aSentence. ! ! !TLOneOfTheMostRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 11:58'! 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 isEmpty! ! TestCase subclass: #TLParagraphTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model-Tests'! !TLParagraphTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 12:06'! testCreation | aParagraph | aParagraph := TLParagraph withAll: (OrderedCollection with: (TLWord with: 2)). self assert: aParagraph sentences size = 1. self assert: aParagraph sentences first text = 2! ! !TLParagraphTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 12:15'! testIsParagraph | aParagraph | aParagraph := TLParagraph withAll: 1. self assert: aParagraph isParagraph. self deny: aParagraph isDocument. self deny: aParagraph isSentence. self deny: aParagraph isWord. self deny: aParagraph isPunctuation. self deny: aParagraph isEndOfDocument. self deny: aParagraph isWhitespace.! ! TestCase subclass: #TLPunctuationMarkTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model-Tests'! !TLPunctuationMarkTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 13:52'! testCreation | aToken | aToken := TLPunctuationMark with: 1. self assert: aToken text = 1! ! !TLPunctuationMarkTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 14:17'! testIsEndOfSentence | aToken | aToken := TLPunctuationMark with: (PPToken on: '.'). self assert: aToken isEndOfSentence. aToken := TLPunctuationMark with: (PPToken on: ';'). self assert: aToken isEndOfSentence. aToken := TLPunctuationMark with: (PPToken on: ':'). self assert: aToken isEndOfSentence. aToken := TLPunctuationMark with: (PPToken on: '!!'). self assert: aToken isEndOfSentence. aToken := TLPunctuationMark with: (PPToken on: '?'). self assert: aToken isEndOfSentence. aToken := TLPunctuationMark with: (PPToken on: ','). self deny: aToken isEndOfSentence.! ! !TLPunctuationMarkTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 13:53'! testIsPunctuation | aToken | aToken := TLPunctuationMark with: 1. self assert: aToken isPunctuation. self deny: aToken isParagraph. self deny: aToken isDocument. self deny: aToken isSentence. self deny: aToken isWord. self deny: aToken isEndOfDocument. self deny: aToken isWhitespace.! ! !TLPunctuationMarkTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 13:54'! testText | aToken | aToken := TLPunctuationMark with: (PPToken on: '1') . self assert: aToken text = '1'! ! TestCase subclass: #TLRegardedAsBeingRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules-Tests'! !TLRegardedAsBeingRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:59'! 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. self assert: results first = aSentence. ! ! !TLRegardedAsBeingRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:59'! 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. self assert: results first = aSentence. ! ! !TLRegardedAsBeingRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 11:59'! 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 isEmpty! ! TestCase subclass: #TLRequireToRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules-Tests'! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 23:00'! 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. self assert: results first = aSentence. ! ! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 23:00'! 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. self assert: results first = aSentence. ! ! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 11:59'! 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 isEmpty! ! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 23:00'! 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 first = aSentence. self assert: results size = 1. ! ! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 23:00'! 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. self assert: results first = aSentence. ! ! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 11:59'! 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 isEmpty! ! TestCase subclass: #TLRuleFailureTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Runner-Tests'! !TLRuleFailureTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:37'! testCreation | aFailure | aFailure := TLRuleFailure on: 1 at: 2. self assert: aFailure rule = 1. self assert: aFailure element = 2! ! TestCase subclass: #TLRulesArchitectureTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules-Tests'! !TLRulesArchitectureTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 22:34'! testName TLTextLintRule allSubclassesDo: [ :aClass | aClass new name size > 10 ]. ! ! !TLRulesArchitectureTest 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-Model-Tests'! !TLSentenceTest class methodsFor: 'accessing' stamp: 'lr 4/5/2010 00:55'! packageNamesUnderTest ^ #('TextLint-Tests')! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 11:59'! 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/7/2010 11:59'! 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/7/2010 11:59'! 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/7/2010 11:59'! 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/8/2010 10:49'! testCreation | aSentence | aSentence := TLSentence withAll: 1. self assert: aSentence children = 1! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 12:17'! testIsSentence | aSentence | aSentence := TLSentence withAll: 1. self assert: aSentence isSentence. self deny: aSentence isParagraph. self deny: aSentence isDocument. self deny: aSentence isWord. self deny: aSentence isPunctuation. self deny: aSentence isEndOfDocument. self deny: aSentence isWhitespace.! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 15:31'! testWords | aSentence tokens| tokens := OrderedCollection new. tokens add: (TLWord with: (PPToken on: '1')). tokens add: (TLWord with: (PPToken on: '2')). tokens add: (TLWhitespace with: (PPToken on: ' ')). aSentence := TLSentence withAll: tokens. self assert: aSentence words size = 2. self assert: aSentence words first text = '1'. self assert: aSentence words last text = '2'.! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 11:59'! 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/7/2010 11:59'! 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: #TLTerminatorMarkTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model-Tests'! !TLTerminatorMarkTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 14:19'! testCreation | aToken | aToken := TLTerminatorMark with: 1. self assert: aToken text = 1! ! !TLTerminatorMarkTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 14:20'! testIsEndOfDocument | aToken | aToken := TLTerminatorMark with: 1. self assert: aToken isEndOfDocument. self deny: aToken isParagraph. self deny: aToken isDocument. self deny: aToken isSentence. self deny: aToken isWord. self deny: aToken isPunctuation. self deny: aToken isWhitespace.! ! !TLTerminatorMarkTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 14:20'! testText | aToken | aToken := TLTerminatorMark with: (PPToken on: '1') . self assert: aToken text = '1'! ! TestCase subclass: #TLTextLintCheckerTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Runner-Tests'! !TLTextLintCheckerTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 12:00'! testCheckSingleRule | aChecker | aChecker := TLTextLintChecker new. aChecker addRule: (TLALotRule new). aChecker check: 'test a lot that.'. self assert: ( aChecker results size = 1 ). self assert: ( aChecker results first element wordsAsString = ' test a lot that' ). self assert: ( aChecker results first rule class = TLALotRule ) ! ! TestCase subclass: #TLTextLintRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules-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-Parser-Tests'! !TLTextParserTest methodsFor: 'utilities' stamp: 'lr 4/6/2010 22:16'! parse: aString | document | document := TLTextPhraser parse: (TLTextTokenizer parse: aString) onError: [ :err | self error: err printString ]. self assert: document text = aString description: 'Parse invariant not satisfied'. ^ document! ! !TLTextParserTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 16:14'! testSimple | document | document := self parse: 'text1 text2.'. self assert: document text = 'text1 text2.'. self assert: document paragraphs size = 1. self assert: document sentences size = 1. self assert: document words size = 2. self assert: document words first text = 'text1'. self assert: document words second text = 'text2'.! ! !TLTextParserTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 16:15'! testTextWithPunctuationMarks | document | document := self parse: 'text1, hal !! text2.'. self assert: document paragraphs size = 1. self assert: document sentences size = 2. self assert: document words size = 3. self assert: document words first text = 'text1'. self assert: document words second text = 'hal'. self assert: document words last text = 'text2'.! ! !TLTextParserTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 16:31'! testTwoParagraphs | document | document := self parse: 'text1 text2. text.'. self assert: document paragraphs size = 2. self assert: document sentences size = 2. self assert: document words size = 3. self assert: document words first text = 'text1'. self assert: document words second text = 'text2'. self assert: document words last text = 'text'! ! TestCase subclass: #TLTheFactIsRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules-Tests'! !TLTheFactIsRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 23:00'! 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. self assert: results first = aSentence. ! ! !TLTheFactIsRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 23:01'! 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. self assert: results first = aSentence. ! ! !TLTheFactIsRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 12:00'! 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 isEmpty! ! TestCase subclass: #TLTheFactThatRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules-Tests'! !TLTheFactThatRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 23:01'! 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. self assert: results first = aSentence. ! ! !TLTheFactThatRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 23:01'! 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. self assert: results first = aSentence. ! ! !TLTheFactThatRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 12:00'! 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 isEmpty! ! TestCase subclass: #TLTheTruthIsRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules-Tests'! !TLTheTruthIsRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 23:01'! 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. self assert: results first = aSentence. ! ! !TLTheTruthIsRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 23:01'! 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. self assert: results first = aSentence. ! ! !TLTheTruthIsRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 12:00'! 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 isEmpty! ! TestCase subclass: #TLWhitespaceTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model-Tests'! !TLWhitespaceTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 14:24'! testCreation | aToken | aToken := TLWhitespace with: 1. self assert: aToken text = 1! ! !TLWhitespaceTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 15:14'! testIsEndOfParagraph | aToken aWhitespace| aToken := PPToken on: 'ab ' start: 1 stop: 3. aWhitespace := TLWhitespace with: aToken. self assert: aWhitespace isEndOfParagraph. ! ! !TLWhitespaceTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 14:25'! testIsWhitespace | aToken | aToken := TLWhitespace with: 1. self assert: aToken isWhitespace. self deny: aToken isParagraph. self deny: aToken isDocument. self deny: aToken isSentence. self deny: aToken isWord. self deny: aToken isPunctuation. self deny: aToken isEndOfDocument.! ! !TLWhitespaceTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 14:25'! testText | aToken | aToken := TLWhitespace with: (PPToken on: '1') . self assert: aToken text = '1'! ! TestCase subclass: #TLWordRepetitionRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules-Tests'! !TLWordRepetitionRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 12:11'! 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. self assert: results first = aWord. ! ! !TLWordRepetitionRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 12:11'! 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. self assert: results first = aWord. ! ! !TLWordRepetitionRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 12:13'! testFailureManyWords | aRule aDocument anotherWord aSentence words sentences aParagraph paragraphs results aWord | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'tes')). words add: (aWord := 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. self assert: results first = aWord. ! ! !TLWordRepetitionRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 12:14'! testFailureThreeInRow | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (aWord := TLWord with: (PPToken on: 'test')). words add: (anotherWord := 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. self assert: results first = aWord. self assert: results second = anotherWord. ! ! !TLWordRepetitionRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 12:01'! 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 isEmpty! ! TestCase subclass: #TLWordTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model-Tests'! !TLWordTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 12:01'! testCreation | aWord | aWord := TLWord with: 1. self assert: aWord token = 1! ! !TLWordTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 12:20'! testIsWord | aWord | aWord := TLWord with: 1. self assert: aWord isWord. self deny: aWord isParagraph. self deny: aWord isDocument. self deny: aWord isSentence. self deny: aWord isPunctuation. self deny: aWord isEndOfDocument. self deny: aWord isWhitespace.! ! !TLWordTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 12:01'! testText | aWord | aWord := TLWord with: (PPToken on: '1') . self assert: aWord text = '1'! ! WizardPart subclass: #TLCheckboxPart instanceVariableNames: 'model label checkbox' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Wizard'! !TLCheckboxPart class methodsFor: 'instance creation' stamp: 'FabrizioPerin 4/6/2010 17:42'! new: aString ^self new initialize: aString; yourself.! ! !TLCheckboxPart methodsFor: 'accessing' stamp: 'FabrizioPerin 4/7/2010 16:26'! checkboxContentMorph ^checkbox! ! !TLCheckboxPart methodsFor: 'as yet unclassified' stamp: 'FabrizioPerin 4/7/2010 15:24'! checkboxInitializer checkbox := self newCheckboxFor: (model := ValueHolder new contents: true) getSelected: #contents setSelected: #contents: label: label. checkbox buttonMorph selected: true. ^checkbox! ! !TLCheckboxPart methodsFor: 'initialization' stamp: 'FabrizioPerin 4/7/2010 15:24'! initialize: aString super initialize. label := aString. self populateContents: {( self checkboxInitializer )}.! ! !TLCheckboxPart methodsFor: 'as yet unclassified' stamp: 'FabrizioPerin 4/6/2010 17:42'! outputValue "this method is an abstract method as only the subclass itself know what is the information to send to the WizardPane which will send it to the wizarControl " "return true or false according the checkbox is selected or not" ^ model contents! ! !TLCheckboxPart methodsFor: 'accessing' stamp: 'FabrizioPerin 4/6/2010 17:42'! selected: trueOrFalse "select or unselect the checkbox according the value of trueOrFalse " checkbox buttonMorph selected: trueOrFalse.! ! WizardPart subclass: #TLChooseFilePart instanceVariableNames: 'folderDialog title fileDialog' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Wizard'! !TLChooseFilePart methodsFor: 'as yet unclassified' stamp: 'FabrizioPerin 4/7/2010 16:38'! chooseFile fileDialog := FileDialogWindow basicNew initialize; title: title; answerOpenFile. ^self fileDialogContentMorph! ! !TLChooseFilePart methodsFor: 'as yet unclassified' stamp: 'FabrizioPerin 4/7/2010 16:37'! fileDialogContentMorph "exact copy of newContentMorph method but instead to create a new list of directory it uses the one already present" fileDialog directoryTreeMorph: fileDialog directoryTreeMorph; fileListMorph: fileDialog fileListMorph; previewMorph: fileDialog newPreviewMorph. ^(fileDialog newRow: { fileDialog newColumn: { fileDialog newGroupbox: 'Directory' translated for: fileDialog directoryTreeMorph. (fileDialog newLabelGroup: { 'File name' translated->fileDialog newFileNameTextEntry}) vResizing: #shrinkWrap}. fileDialog newGroupbox: 'File' translated forAll: { fileDialog fileListMorph. fileDialog newActionButtonRow}}, (fileDialog previewMorph notNil ifTrue: [{fileDialog newGroupbox: 'Preview' translated for: fileDialog previewMorph}] ifFalse: [#()])) vResizing: #spaceFill.! ! !TLChooseFilePart methodsFor: 'initialization' stamp: 'FabrizioPerin 4/7/2010 16:38'! initialize super initialize. title := ''. self populateContents: {( self chooseFile )}.! ! !TLChooseFilePart methodsFor: 'as yet unclassified' stamp: 'FabrizioPerin 4/7/2010 16:37'! outputValue "this method is an abstract method as only the subclass itself know what is the information to send to the WizardPane which will send it to the wizarControl " ^fileDialog selectedPathName! ! WizardPart subclass: #TLMultiCheckboxesPart instanceVariableNames: 'allCheckboxes' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Wizard'! !TLMultiCheckboxesPart class methodsFor: 'instance creation' stamp: 'FabrizioPerin 4/7/2010 16:14'! groupName: aString withAll: aCollectionOfLabels super initialize. ^self new initialize: aCollectionOfLabels inGroupBoxNamed: aString. ! ! !TLMultiCheckboxesPart methodsFor: 'initialize-release' stamp: 'FabrizioPerin 4/7/2010 16:28'! initialize: aCollectionOfLabels inGroupBoxNamed: aName allCheckboxes := OrderedCollection new. aCollectionOfLabels do: [:each | allCheckboxes add: ((TLCheckboxPart new: each) checkboxContentMorph). ]. "elements := self addVerticalSeparatorAtTheMiddleOf: allCheckboxes ." self populateContents: {self newGroupboxNamed: aName WithAll: allCheckboxes} ! ! !TLMultiCheckboxesPart methodsFor: 'accessing - wizard mangement' stamp: 'FabrizioPerin 4/7/2010 16:05'! outputValue "this method is an abstract method as only the subclass itself know what is the information to send to the WizardPane which will send it to the wizarControl " ^ self selectedItems! ! !TLMultiCheckboxesPart methodsFor: 'accessing - wizard mangement' stamp: 'FabrizioPerin 4/7/2010 16:05'! selectedItems "return a collection containing symbols corresponding to the checkboxes selected" | result | result := OrderedCollection new. allCheckboxes do: [ :each | each buttonMorph selected ifTrue: [ result add: each label asSymbol ] ]. ^ result! ! PPCompositeParser subclass: #TLTextPhraser instanceVariableNames: 'document documentTerminator paragraph paragraphTerminator sentence sentenceTerminator' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Parser'! !TLTextPhraser methodsFor: 'grammar' stamp: 'lr 4/6/2010 22:06'! document ^ (paragraph starLazy: documentTerminator) , (documentTerminator optional) ==> [ :nodes | TLDocument withAll: nodes first ]! ! !TLTextPhraser methodsFor: 'grammar' stamp: 'lr 4/6/2010 22:03'! documentTerminator ^ PPPredicateParser on: [ :token | token isEndOfDocument ] message: 'End of document expected'! ! !TLTextPhraser methodsFor: 'grammar' stamp: 'lr 4/6/2010 22:05'! paragraph ^ (sentence starLazy: paragraphTerminator / documentTerminator) , (paragraphTerminator optional) ==> [ :nodes | TLParagraph withAll: (nodes last isNil ifFalse: [ nodes first copyWith: nodes last ] ifTrue: [ nodes first ]) ]! ! !TLTextPhraser methodsFor: 'grammar' stamp: 'lr 4/6/2010 21:45'! paragraphTerminator ^ PPPredicateParser on: [ :token | token isWhitespace and: [ token isEndOfParagraph ] ] message: 'End of paragraph expected'! ! !TLTextPhraser methodsFor: 'grammar' stamp: 'lr 4/6/2010 22:04'! sentence ^ (#any asParser starLazy: sentenceTerminator / paragraphTerminator / documentTerminator) , (sentenceTerminator optional) ==> [ :nodes | TLSentence withAll: (nodes last isNil ifFalse: [ nodes first copyWith: nodes last ] ifTrue: [ nodes first ]) ]! ! !TLTextPhraser methodsFor: 'grammar' stamp: 'lr 4/6/2010 21:27'! sentenceTerminator ^ PPPredicateParser on: [ :token | token isPunctuation and: [ token isEndOfSentence ] ] message: 'End of sentence expected'! ! !TLTextPhraser methodsFor: 'accessing' stamp: 'lr 4/6/2010 21:43'! start ^ document end! ! PPCompositeParser subclass: #TLTextTokenizer instanceVariableNames: 'elementList element word whitespace punctuation' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Parser'! !TLTextTokenizer methodsFor: 'grammar' stamp: 'lr 4/6/2010 20:20'! element ^ word / whitespace / punctuation! ! !TLTextTokenizer methodsFor: 'grammar' stamp: 'JorgeRessia 4/7/2010 15:06'! elementList ^ element star ==> [ :nodes | nodes copyWith: (TLTerminatorMark with: '') ]! ! !TLTextTokenizer methodsFor: 'tokens' stamp: 'JorgeRessia 4/7/2010 15:05'! punctuation ^ #any asParser token ==> [ :node | TLPunctuationMark with: node ]! ! !TLTextTokenizer methodsFor: 'accessing' stamp: 'lr 4/6/2010 20:21'! start ^ elementList end! ! !TLTextTokenizer methodsFor: 'tokens' stamp: 'JorgeRessia 4/7/2010 15:05'! whitespace ^ #space asParser plus token ==> [ :node | TLWhitespace with: node ]! ! !TLTextTokenizer methodsFor: 'tokens' stamp: 'JorgeRessia 4/7/2010 15:04'! word ^ #word asParser plus token ==> [ :node | TLWord with: node ]! ! Object subclass: #TLElement instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! TLElement 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: 'accessing' stamp: 'lr 4/6/2010 21:15'! children ^ paragraphs! ! !TLDocument methodsFor: 'initialization' stamp: 'lr 4/6/2010 20:25'! initializeFromString: aString! ! !TLDocument methodsFor: 'initialization' stamp: 'lr 3/31/2010 11:16'! initializeWithAll: aCollection paragraphs := aCollection! ! !TLDocument methodsFor: 'testing' stamp: 'JorgeRessia 4/7/2010 12:11'! isDocument ^ true! ! !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 ]! ! !TLElement methodsFor: 'accessing' stamp: 'lr 4/6/2010 20:30'! children "Answer the children nodes." ^ #() ! ! !TLElement methodsFor: 'testing' stamp: 'JorgeRessia 4/7/2010 12:11'! isDocument ^ false! ! !TLElement methodsFor: 'testing' stamp: 'JorgeRessia 4/7/2010 11:44'! isEndOfDocument ^ false! ! !TLElement methodsFor: 'testing' stamp: 'JorgeRessia 4/7/2010 12:11'! isParagraph ^ false! ! !TLElement methodsFor: 'testing' stamp: 'JorgeRessia 4/7/2010 11:44'! isPunctuation ^ false! ! !TLElement methodsFor: 'testing' stamp: 'JorgeRessia 4/7/2010 12:10'! isSentence ^ false! ! !TLElement methodsFor: 'testing' stamp: 'JorgeRessia 4/7/2010 11:44'! isWhitespace ^ false! ! !TLElement methodsFor: 'testing' stamp: 'JorgeRessia 4/7/2010 11:44'! isWord ^ false! ! !TLElement methodsFor: 'printing' stamp: 'JorgeRessia 4/8/2010 10:49'! printContentOn: aStream self children do: [ :each | aStream nextPutAll: each text ]! ! !TLElement methodsFor: 'accessing' stamp: 'lr 4/6/2010 22:09'! text ^ String streamContents: [ :stream | self printContentOn: stream ]! ! TLElement subclass: #TLParagraph instanceVariableNames: 'sentences' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLParagraph class methodsFor: 'instance creation' stamp: 'JorgeRessia 4/7/2010 11:13'! withAll: aCollection ^self new initializeWithAll: aCollection! ! !TLParagraph methodsFor: 'accessing' stamp: 'lr 4/6/2010 21:15'! children ^ sentences! ! !TLParagraph methodsFor: 'initialization' stamp: 'lr 3/31/2010 11:17'! initializeWithAll: aCollection sentences := aCollection! ! !TLParagraph methodsFor: 'testing' stamp: 'JorgeRessia 4/7/2010 12:11'! isParagraph ^ true! ! !TLParagraph methodsFor: 'accessing' stamp: 'JorgeRessia 4/7/2010 11:13'! sentences ^sentences reject: [:eachElement | eachElement isWhitespace]! ! TLElement subclass: #TLSentence instanceVariableNames: 'syntacticElements' 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: 'accessing' stamp: 'JorgeRessia 4/8/2010 11:08'! children ^ syntacticElements! ! !TLSentence methodsFor: 'testing' stamp: 'lr 4/5/2010 10:25'! containsPhrase: aString ^ self wordsAsString includesSubstring: aString caseSensitive: false! ! !TLSentence methodsFor: 'initialization' stamp: 'JorgeRessia 4/8/2010 11:08'! initializeWithAll: aCollection syntacticElements := aCollection! ! !TLSentence methodsFor: 'testing' stamp: 'JorgeRessia 4/7/2010 12:12'! isSentence ^ true! ! !TLSentence methodsFor: 'accessing' stamp: 'JorgeRessia 4/8/2010 11:08'! words ^ syntacticElements select: [:eachToken | eachToken isWord ]! ! !TLSentence methodsFor: 'accessing' stamp: 'JorgeRessia 4/7/2010 15:24'! wordsAsString ^self words inject: '' into: [:count :each | count, ' ', each text] ! ! TLElement subclass: #TLSyntacticElement instanceVariableNames: 'token' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! TLSyntacticElement subclass: #TLPunctuationMark instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLPunctuationMark class methodsFor: 'streaming' stamp: 'JorgeRessia 4/7/2010 12:09'! with: aToken ^self new initializeWith: aToken! ! !TLPunctuationMark methodsFor: 'initialization' stamp: 'JorgeRessia 4/7/2010 12:09'! initializeWith: aToken token := aToken! ! !TLPunctuationMark methodsFor: 'testing' stamp: 'JorgeRessia 4/7/2010 13:58'! isEndOfSentence ^ '.:;!!?' includes: (token collection at: token start)! ! !TLPunctuationMark methodsFor: 'testing' stamp: 'lr 4/6/2010 20:44'! isPunctuation ^ true! ! !TLSyntacticElement methodsFor: 'printing' stamp: 'JorgeRessia 4/7/2010 15:16'! printContentOn: aStream self tokens do: [ :each | aStream nextPutAll: each value ]! ! !TLSyntacticElement methodsFor: 'printing' stamp: 'JorgeRessia 4/7/2010 15:17'! printOn: aStream super printOn: aStream. aStream nextPutAll: ' ('. self printContentOn: aStream. aStream nextPut: $)! ! !TLSyntacticElement methodsFor: 'accessing' stamp: 'JorgeRessia 4/7/2010 13:54'! text ^ token value! ! !TLSyntacticElement methodsFor: 'accessing' stamp: 'JorgeRessia 4/8/2010 10:56'! token ^ token! ! !TLSyntacticElement methodsFor: 'accessing' stamp: 'JorgeRessia 4/7/2010 15:20'! tokens ^ Array with: token! ! TLSyntacticElement subclass: #TLTerminatorMark instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLTerminatorMark class methodsFor: 'streaming' stamp: 'JorgeRessia 4/7/2010 12:09'! with: aToken ^self new initializeWith: aToken! ! !TLTerminatorMark methodsFor: 'initialization' stamp: 'JorgeRessia 4/7/2010 12:09'! initializeWith: aToken token := aToken! ! !TLTerminatorMark methodsFor: 'testing' stamp: 'lr 4/6/2010 22:04'! isEndOfDocument ^ true! ! TLSyntacticElement subclass: #TLWhitespace instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLWhitespace class methodsFor: 'streaming' stamp: 'JorgeRessia 4/7/2010 12:08'! with: aToken ^self new initializeWith: aToken! ! !TLWhitespace methodsFor: 'initialization' stamp: 'JorgeRessia 4/7/2010 12:09'! initializeWith: aToken token := aToken! ! !TLWhitespace methodsFor: 'testing' stamp: 'JorgeRessia 4/7/2010 15:09'! isEndOfParagraph token start to: token stop do: [ :index | (String crlf includes: (token collection at: index)) ifTrue: [ ^ true ] ]. ^ false! ! !TLWhitespace methodsFor: 'testing' stamp: 'lr 4/6/2010 21:45'! isWhitespace ^ true! ! TLSyntacticElement subclass: #TLWord instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLWord class methodsFor: 'instance creation' stamp: 'JorgeRessia 4/7/2010 11:52'! with: aToken ^self new initializeWith: aToken! ! !TLWord methodsFor: 'initialization' stamp: 'JorgeRessia 4/7/2010 11:52'! initializeWith: aToken token := aToken! ! !TLWord methodsFor: 'testing' stamp: 'lr 4/6/2010 20:44'! isWord ^ true! ! !TLWord methodsFor: 'accessing' stamp: 'JorgeRessia 4/7/2010 11:52'! text ^token value! ! !TLWord methodsFor: 'accessing' stamp: 'JorgeRessia 4/7/2010 11:52'! token ^ token! ! !TLWord methodsFor: 'accessing' stamp: 'JorgeRessia 4/7/2010 11:52'! tokens ^ Array with: token! ! Object subclass: #TLRuleFailure instanceVariableNames: 'rule element' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Runner'! !TLRuleFailure class methodsFor: 'instance creation' stamp: 'JorgeRessia 4/6/2010 15:54'! on: aRule at: anElement ^self new initializeOn: aRule at: anElement! ! !TLRuleFailure methodsFor: 'accessing' stamp: 'JorgeRessia 4/6/2010 16:00'! element ^ element! ! !TLRuleFailure methodsFor: 'initialization' stamp: 'JorgeRessia 4/6/2010 15:55'! initializeOn: aRule at: anElement rule := aRule. element := anElement! ! !TLRuleFailure methodsFor: 'accessing' stamp: 'JorgeRessia 4/6/2010 16:00'! rule ^ rule! ! Object subclass: #TLTextLintChecker instanceVariableNames: 'rules results' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Runner'! !TLTextLintChecker methodsFor: 'accessing' stamp: 'JorgeRessia 3/31/2010 16:49'! addRule: aRule rules add: aRule! ! !TLTextLintChecker methodsFor: 'public' stamp: 'lr 4/6/2010 22:21'! check: aString | aDocument | aDocument := TLTextPhraser parse: (TLTextTokenizer parse: aString). self checkDocument: aDocument.! ! !TLTextLintChecker methodsFor: 'mocking' stamp: 'JorgeRessia 4/6/2010 15:58'! checkDocument: aDocument results := rules gather: [ :rule | (rule runOn: aDocument) collect: [:element | TLRuleFailure on: rule at: element]]! ! !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-Rules'! TLTextLintRule subclass: #TLALotRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules'! !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-Rules'! !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-Rules'! !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-Rules'! !TLAvoidQualifiersRule methodsFor: 'initialization' stamp: 'lr 4/6/2010 22:25'! initialize super initialize. self initializeQualifiers.! ! !TLAvoidQualifiersRule methodsFor: 'initialization' stamp: 'lr 4/6/2010 22:25'! initializeQualifiers 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-Rules'! !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-Rules'! !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/8/2010 12:21'! runOn: aDocument | results sentences | results := OrderedCollection new. sentences := aDocument sentences reject: [ :eachSentence | eachSentence words isEmpty]. sentences do: [:eachSentence | (eachSentence words first text translateToLowercase = 'however') ifTrue: [ results add: eachSentence words first] ]. ^results ! ! TLTextLintRule subclass: #TLOneOfTheMostRule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Rules'! !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-Rules'! !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-Rules'! !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-Rules'! !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-Rules'! !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-Rules'! !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-Rules'! !TLWordRepetitionRule methodsFor: 'accessing' stamp: 'JorgeRessia 4/2/2010 18:22'! rationale ^ 'Detection of words repetion'! ! !TLWordRepetitionRule methodsFor: 'running' stamp: 'JorgeRessia 4/8/2010 12:11'! runOn: aDocument | words results | results := OrderedCollection new. aDocument sentences do: [:eachSentence | words := eachSentence words asArray. 2 to: words size do: [:index | ((words at: index) text translateToLowercase = (words at: index - 1) text translateToLowercase) ifTrue: [ results add: (words at: index - 1)] ] ]. ^results ! !