SystemOrganization addCategory: #'TextLint-Tests-Model'! SystemOrganization addCategory: #'TextLint-Tests-Parser'! SystemOrganization addCategory: #'TextLint-Tests-Runner'! SystemOrganization addCategory: #'TextLint-Tests-Rules'! TestCase subclass: #TLALotRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !TLALotRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 14:23'! testFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'A')). words add: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'A'. self assert: results first words last text = 'lot'. ! ! !TLALotRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 15:37'! testFailureCaseInsensitive | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'A')). words add: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'A'. self assert: results first words last text = 'LOT'. ! ! !TLALotRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 15: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: 'a')). words add: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'a'. self assert: results first words last text = 'Lot'. ! ! !TLALotRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 10:18'! 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 := TLALotRule new. results := aRule runOn: aDocument. self assert: results isEmpty. ! ! TestCase subclass: #TLAllowToRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 21:41'! testAllowToFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results| words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'Allow')). words add: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'Allow'. self assert: results first words last text = 'to'. ! ! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 21:42'! testAllowToFailureCaseInsensitive | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results| words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'Allow')). words add: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'Allow'. self assert: results first words last text = 'TO'. ! ! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 21:43'! 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: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'Allow'. self assert: results first words last text = 'to'. ! ! !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/12/2010 21:44'! testAllowsToFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'Allows')). words add: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'Allows'. self assert: results first words last text = 'to'. ! ! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 21:44'! testAllowsToFailureCaseInsensitive | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'ALLOWS')). words add: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'ALLOWS'. self assert: results first words last text = 'TO'. ! ! !TLAllowToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 21:45'! 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: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'Allows'. self assert: results first words last text = 'to'. ! ! !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: #TLAnyNumberOfOcurrenciesPatternTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !TLAnyNumberOfOcurrenciesPatternTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 09:27'! testConsumeFrom | aPattern aWord anotherWord elements aPhrase aWhitespace anIndexedElement | aPattern := TLAnyNumberOfOcurrenciesPattern of: (TLWord with: (PPToken on: 'allow')). elements := OrderedCollection new. elements add: (TLWord with: (PPToken on: 'allow')). elements add: (aWhitespace := TLWhitespace with: (PPToken on: ' ')). elements add: (TLWord with: (PPToken on: 'to')). aPhrase := TLPhrase withAll: elements. anIndexedElement := TLIndexedElement of: aPhrase. aPattern consumeFrom: anIndexedElement . self assert: (anIndexedElement instVarNamed: 'index') = 2. self assert: anIndexedElement current = aWhitespace ! ! !TLAnyNumberOfOcurrenciesPatternTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 09:27'! testConsumeFromMultiple | aPattern aWord anotherWord elements aPhrase aWhitespace anIndexedElement | aPattern := TLAnyNumberOfOcurrenciesPattern of: (TLWord with: (PPToken on: 'allow')). elements := OrderedCollection new. elements add: (TLWord with: (PPToken on: 'allow')). elements add: (TLWord with: (PPToken on: 'allow')). elements add: (aWhitespace := TLWhitespace with: (PPToken on: ' ')). elements add: (TLWord with: (PPToken on: 'to')). aPhrase := TLPhrase withAll: elements. anIndexedElement := TLIndexedElement of: aPhrase. aPattern consumeFrom: anIndexedElement . self assert: (anIndexedElement instVarNamed: 'index') = 3. self assert: anIndexedElement current = aWhitespace ! ! !TLAnyNumberOfOcurrenciesPatternTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 21:38'! testCreation | aPattern aWord anotherWord elements aPhrase | aPattern := TLAnyNumberOfOcurrenciesPattern of: 1. self assert: (aPattern instVarNamed: 'element' ) = 1. ! ! TestCase subclass: #TLAnyOfSetPatternTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !TLAnyOfSetPatternTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 21:04'! testConsumeFrom | aPattern aWord anotherWord elements aPhrase aWhitespace anIndexedElement aSet | elements := OrderedCollection new. elements add: (TLWord with: (PPToken on: 'allow')). elements add: (aWhitespace := TLWhitespace with: (PPToken on: ' ')). elements add: (TLWord with: (PPToken on: 'to')). aPhrase := TLPhrase withAll: elements. anIndexedElement := TLIndexedElement of: aPhrase. aSet := OrderedCollection with: (TLWord with: (PPToken on: 'allow')) with: (TLWord with: (PPToken on: 'allows')). aPattern := TLAnyOfSetPattern of: aSet. self assert: (aPattern consumeFrom: anIndexedElement ). self assert: anIndexedElement current = aWhitespace ! ! !TLAnyOfSetPatternTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 21:02'! testCreation | aPattern aWord anotherWord elements aPhrase | aPattern := TLAnyOfSetPattern of: 1. self assert: (aPattern instVarNamed: 'elements' ) = 1. ! ! TestCase subclass: #TLAsToWhetherRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !TLAsToWhetherRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 11:13'! testFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'As')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'As'. self assert: results first words second text = 'to'. self assert: results first words last text = 'whether'. ! ! !TLAsToWhetherRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 11:14'! testFailureCaseInsensitive | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'AS')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (TLWord with: (PPToken on: 'TO')). words add: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'AS'. self assert: results first words second text = 'TO'. self assert: results first words last text = 'WHETHER'. ! ! !TLAsToWhetherRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 11:15'! 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: (TLWhitespace with: (PPToken on: ' ')). words add: (TLWord with: (PPToken on: 'to')). words add: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'as'. self assert: results first words second text = 'to'. self assert: results first words last text = 'Whether'. ! ! !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-Tests-Rules'! !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: 'FabrizioPerin 4/11/2010 13:05'! testReallyFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | aWord := TLWord with: (PPToken on: 'really'). 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: #TLCaseInsensitiveWordPatternTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !TLCaseInsensitiveWordPatternTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 09:46'! testCreation | aPattern | aPattern := TLCaseInsensitiveWordPattern on: 'ab'. self assert: (aPattern matches: 'ab'). self assert: (aPattern matches: 'AB'). self assert: (aPattern matches: 'aB'). self assert: (aPattern matches: 'Ab').! ! TestCase subclass: #TLContinuousWordRepetitionRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !TLContinuousWordRepetitionRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 10:03'! 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 := TLContinuousWordRepetitionRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! !TLContinuousWordRepetitionRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 10:03'! 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 := TLContinuousWordRepetitionRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! !TLContinuousWordRepetitionRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 10:03'! 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 := TLContinuousWordRepetitionRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! !TLContinuousWordRepetitionRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 10:03'! 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 := TLContinuousWordRepetitionRule new. results := aRule runOn: aDocument. self assert: results size = 2. self assert: results first = aWord. self assert: results second = anotherWord. ! ! !TLContinuousWordRepetitionRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 10:03'! 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 := TLContinuousWordRepetitionRule new. results := aRule runOn: aDocument. self assert: results isEmpty! ! TestCase subclass: #TLDocumentTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Model'! !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/9/2010 11:21'! testEmptyInterval | aDocument words aSentence aParagraph sentences paragraphs| words := OrderedCollection new. aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. self assert: aDocument interval size = 0! ! !TLDocumentTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 11:20'! testInterval | aDocument words aSentence aParagraph sentences paragraphs| words := OrderedCollection new. words add: (TLWord with: (PPToken on: '1' start: 1 stop: 1 )). words add: (TLWord with: (PPToken on: '2' start: 2 stop: 2 )). words add: (TLWord with: (PPToken on: '3' start: 3 stop: 3 )). words add: (TLWord with: (PPToken on: '4' start: 4 stop: 4 )). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. self assert: aDocument interval size = 4 ! ! !TLDocumentTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 14:04'! 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. self deny: aDocument isPhrase.! ! !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/9/2010 13:56'! testText | 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 text = '1234'! ! !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: #TLElementTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Model'! !TLElementTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 11:56'! testChildren | anElement | anElement := TLElement new. self assert: anElement children isEmpty! ! TestCase subclass: #TLHelpToRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 11:34'! testHelpToFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'Help')). words add: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'Help'. self assert: results first words last text = 'to'. ! ! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 11:35'! testHelpToFailureCaseInsensitive | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'HELP')). words add: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'HELP'. self assert: results first words last text = 'TO'. ! ! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 11:34'! 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: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'Help'. self assert: results first words last text = 'to'. ! ! !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/13/2010 11:35'! testHelpsToFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'Helps')). words add: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'Helps'. self assert: results first words last text = 'to'. ! ! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 11:36'! testHelpsToFailureCaseInsensitive | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'HELPS')). words add: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'HELPS'. self assert: results first words last text = 'TO'. ! ! !TLHelpToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 11:36'! 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: (TLWhitespace with: (PPToken on: ' ')). 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 isPhrase. self assert: results first words first text = 'Helps'. self assert: results first words last text = 'to'. ! ! !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-Tests-Rules'! !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: #TLIndexedElementTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !TLIndexedElementTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 20:23'! testCreation | anIndexedElement | anIndexedElement := TLIndexedElement of: 1. self assert: anIndexedElement element = 1! ! !TLIndexedElementTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 20:53'! testNext | anIndexedElement elements element1 element2 element3 aPhrase | elements := OrderedCollection new. elements add: ( element1 := TLWord with: (PPToken on: 'allow')). elements add: ( element2 :=TLWhitespace with: (PPToken on: ' ')). elements add: ( element3 :=TLWord with: (PPToken on: 'to')). aPhrase := TLPhrase withAll: elements. anIndexedElement := TLIndexedElement of: aPhrase. self assert: anIndexedElement current = element1. self assert: anIndexedElement next = element2. self assert: anIndexedElement next = element3. self assert: anIndexedElement next = nil! ! TestCase subclass: #TLOneOfTheMostRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !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/8/2010 13:35'! testFailureCaseInsensitive | 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-Tests-Model'! !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/9/2010 11:38'! testEmptyInterval | aParagraph words aSentence anotherSentence sentences | words := OrderedCollection new. words add: (TLWord with: (PPToken on: '1' start: 1stop: 1 )). words add: (TLWord with: (PPToken on: '2' start: 2stop: 2 )). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence with: (TLWhitespace with: (PPToken on: ' ' start: 3 stop: 3 )). aParagraph := TLParagraph withAll: sentences. self assert: aParagraph interval size = 3! ! !TLParagraphTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 11:37'! testInterval | aParagraph words aSentence sentences | words := OrderedCollection new. aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. self assert: aParagraph interval size = 0! ! !TLParagraphTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 14:05'! 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. self deny: aParagraph isPhrase.! ! !TLParagraphTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 11:34'! testSentences | aParagraph words aSentence anotherSentence sentences | aParagraph := TLParagraph withAll: (OrderedCollection with: (TLWord with: '2')). self assert: aParagraph sentences size = 1. self assert: aParagraph sentences first text = '2'. words := OrderedCollection new. words add: (TLWord with: (PPToken on: '1')). words add: (TLWord with: (PPToken on: '2')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence with: (TLWhitespace with: (PPToken on: ' ')). aParagraph := TLParagraph withAll: sentences. self assert: aParagraph sentences size = 1. self assert: aParagraph sentences first text = '12'.! ! !TLParagraphTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 13:57'! testText | aParagraph words aSentence anotherSentence sentences | words := OrderedCollection new. words add: (TLWord with: (PPToken on: '1')). words add: (TLWord with: (PPToken on: '2')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence with: (TLWhitespace with: (PPToken on: ' ')). aParagraph := TLParagraph withAll: sentences. self assert: aParagraph text = '12 '! ! !TLParagraphTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 10:52'! testWords | aParagraph words aSentence anotherSentence sentences | words := OrderedCollection new. words add: (TLWord with: (PPToken on: '2')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. self assert: aParagraph words size = 1. self assert: aParagraph words first text = '2'. words := OrderedCollection new. words add: (TLWord with: (PPToken on: '1')). words add: (TLWord with: (PPToken on: '2')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence with: (TLWhitespace with: (PPToken on: ' ')). aParagraph := TLParagraph withAll: sentences. self assert: aParagraph words size = 2. self assert: aParagraph words first text = '1'. self assert: aParagraph words last text = '2'.! ! TestCase subclass: #TLPhraseTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Model'! !TLPhraseTest class methodsFor: 'accessing' stamp: 'JorgeRessia 4/8/2010 14:58'! packageNamesUnderTest ^ #('TextLint-Tests')! ! !TLPhraseTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 14:59'! testCreation | aPhrase | aPhrase := TLPhrase withAll: 1. self assert: aPhrase children = 1! ! !TLPhraseTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 11:44'! testEmptyInterval | aPhrase words| words := OrderedCollection new. aPhrase := TLPhrase withAll: words. self assert: aPhrase interval size = 0! ! !TLPhraseTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 11:44'! testInterval | aPhrase words| words := OrderedCollection new. words add: (TLWord with: (PPToken on: '1' start: 1 stop: 1 )). words add: (TLWhitespace with: (PPToken on: ' ' start: 2 stop: 2 )). words add: (TLWord with: (PPToken on: '2' start: 3 stop: 3 )). aPhrase := TLPhrase withAll: words. self assert: aPhrase interval size = 3! ! !TLPhraseTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 14:04'! testIsPhrase | aParagraph | aParagraph := TLPhrase withAll: 1. self assert: aParagraph isPhrase. self deny: aParagraph isDocument. self deny: aParagraph isSentence. self deny: aParagraph isWord. self deny: aParagraph isPunctuation. self deny: aParagraph isEndOfDocument. self deny: aParagraph isWhitespace. self deny: aParagraph isParagraph.! ! !TLPhraseTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 15:02'! testText | aPhrase words| words := OrderedCollection new. words add: (TLWord with: (PPToken on: '1')). words add: (TLWord with: (PPToken on: '2')). aPhrase := TLPhrase withAll: words. self assert: aPhrase text = '12'! ! !TLPhraseTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 15:15'! testTextWithSyntacticElements | aPhrase words| words := OrderedCollection new. words add: (TLWord with: (PPToken on: '1')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (TLWord with: (PPToken on: '2')). aPhrase := TLPhrase withAll: words. self assert: aPhrase text = '1 2'! ! !TLPhraseTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 15:00'! testWords | aPhrase tokens| tokens := OrderedCollection new. tokens add: (TLWord with: (PPToken on: '1')). tokens add: (TLWord with: (PPToken on: '2')). tokens add: (TLWhitespace with: (PPToken on: ' ')). aPhrase := TLPhrase withAll: tokens. self assert: aPhrase words size = 2. self assert: aPhrase words first text = '1'. self assert: aPhrase words last text = '2'.! ! TestCase subclass: #TLPunctuationMarkTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Model'! !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/9/2010 11:52'! testInterval | aToken | aToken := TLPunctuationMark with: (PPToken on: '.' start: 1 stop: 1) . self assert: aToken interval size = 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/9/2010 14:05'! 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. self deny: aToken isPhrase.! ! !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-Tests-Rules'! !TLRegardedAsBeingRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 11:48'! testFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results word1 word2 word3 | words := OrderedCollection new. words add: (word1 := TLWord with: (PPToken on: 'Regarded')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (word2 := TLWord with: (PPToken on: 'as')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (word3 := 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 isPhrase. self assert: results first words first= word1. self assert: results first words second = word2. self assert: results first words last = word3. ! ! !TLRegardedAsBeingRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 11:50'! testFailureCaseInsensitive | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results word1 word2 word3 | words := OrderedCollection new. words add: (word1 := TLWord with: (PPToken on: 'REGARDED')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (word2 := TLWord with: (PPToken on: 'AS')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (word3 := 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 isPhrase. self assert: results first words first= word1. self assert: results first words second = word2. self assert: results first words last = word3. ! ! !TLRegardedAsBeingRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 11:51'! testFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results word1 word2 word3 | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (word1 := TLWord with: (PPToken on: 'Regarded')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (word2 := TLWord with: (PPToken on: 'as')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (word3 := 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 isPhrase. self assert: results first words first= word1. self assert: results first words second = word2. self assert: results first words last = word3. ! ! !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-Tests-Rules'! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 11:59'! testRequireToFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results word1 word2 | words := OrderedCollection new. words add: (word1 := TLWord with: (PPToken on: 'Require')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (word2 := 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 isPhrase. self assert: results first words first= word1. self assert: results first words second = word2. ! ! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 11:59'! testRequireToFailureCaseInsensitive | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results word1 word2 | words := OrderedCollection new. words add: (word1 := TLWord with: (PPToken on: 'REQUIRE')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (word2 := 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 isPhrase. self assert: results first words first= word1. self assert: results first words second = word2. ! ! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 11:59'! testRequireToFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results word1 word2 | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (word1 := TLWord with: (PPToken on: 'Require')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (word2 := 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 isPhrase. self assert: results first words first= word1. self assert: results first words second = word2. ! ! !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/13/2010 11:59'! testRequiresToFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results word1 word2 | words := OrderedCollection new. words add: (word1 := TLWord with: (PPToken on: 'Requires')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (word2 := 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 isPhrase. self assert: results first words first= word1. self assert: results first words second = word2. ! ! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 12:00'! testRequiresToFailureCaseInsensitive | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results word1 word2 | words := OrderedCollection new. words add: (word1 := TLWord with: (PPToken on: 'REQUIRES')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (word2 := 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 isPhrase. self assert: results first words first= word1. self assert: results first words second = word2. ! ! !TLRequireToRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/13/2010 12:00'! testRequiresToFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results word1 word2 | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (word1 := TLWord with: (PPToken on: 'Requires')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (word2 := 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 isPhrase. self assert: results first words first= word1. self assert: results first words second = word2. ! ! !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-Tests-Runner'! !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: #TLRulePatternTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !TLRulePatternTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 21:31'! testCreation | aRulePattern aWord anotherWord elements aPhrase | aRulePattern := TLRulePattern new. aWord := TLWord with: (PPToken on: 'Allow'). anotherWord := TLWord with: (PPToken on: 'Allows'). aRulePattern anyOf: (OrderedCollection with: aWord with: aWord). aRulePattern anyNumberOf: (TLWhitespace with: (PPToken on: ' ')). aRulePattern with: (TLWord with: (PPToken on: 'to')). elements := OrderedCollection new. elements add: (TLWord with: (PPToken on: 'Allow')). elements add: (TLWhitespace with: (PPToken on: ' ')). elements add: (TLWord with: (PPToken on: 'to')). aPhrase := TLPhrase withAll: elements. self assert: (aRulePattern matches: aPhrase)! ! !TLRulePatternTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 21:36'! testCreationAnother | aRulePattern aWord anotherWord elements aPhrase | aRulePattern := TLRulePattern new. aWord := TLWord with: (PPToken on: 'Allow'). anotherWord := TLWord with: (PPToken on: 'Allows'). aRulePattern anyOf: (OrderedCollection with: aWord with: anotherWord). aRulePattern anyNumberOf: (TLWhitespace with: (PPToken on: ' ')). aRulePattern with: (TLWord with: (PPToken on: 'to')). elements := OrderedCollection new. elements add: (TLWord with: (PPToken on: 'Allow')). elements add: (TLWhitespace with: (PPToken on: ' ')). elements add: (TLWord with: (PPToken on: 'to')). aPhrase := TLPhrase withAll: elements. self assert: (aRulePattern matches: aPhrase). elements := OrderedCollection new. elements add: (TLWord with: (PPToken on: 'Allows')). elements add: (TLWhitespace with: (PPToken on: ' ')). elements add: (TLWord with: (PPToken on: 'to')). aPhrase := TLPhrase withAll: elements. self assert: (aRulePattern matches: aPhrase)! ! TestCase subclass: #TLRulesArchitectureTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !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-Tests-Model'! !TLSentenceTest class methodsFor: 'accessing' stamp: 'lr 4/8/2010 13:33'! packageNamesUnderTest ^ #('TextLint-Model')! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 13:59'! testAllPhrasesOfSize | aSentence words phrases | 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')). words add: (TLWord with: (PPToken on: '5')). aSentence := TLSentence withAll: words. phrases := aSentence allPhrasesOfSize: 3. self assert: phrases size = 3. self assert: phrases first text = '123'. self assert: phrases second text = '234'. self assert: phrases last text = '345'.! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 13:59'! testAllPhrasesOfSizeOne | aSentence words phrases aWord | words := OrderedCollection new. words add: (aWord := TLWord with: (PPToken on: '1')). aSentence := TLSentence withAll: words. phrases := aSentence allPhrasesOfSize: 1. self assert: phrases size = 1. self assert: phrases first words size = 1. self assert: phrases first words first = aWord.! ! !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/9/2010 11:48'! testEmptyInterval | aSentence words| words := OrderedCollection new. aSentence := TLSentence withAll: words. self assert: aSentence interval size = 0! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 11:47'! testInterval | aSentence words| words := OrderedCollection new. words add: (TLWord with: (PPToken on: '1' start: 1 stop: 1)). words add: (TLWord with: (PPToken on: '2' start: 2 stop: 2)). words add: (TLWhitespace with: (PPToken on: ' ' start: 3 stop: 3)). aSentence := TLSentence withAll: words. self assert: aSentence interval size = 3! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 14:05'! 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. self deny: aSentence isPhrase.! ! !TLSentenceTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 13:54'! testText | 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 text = '12 '! ! !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: #TLSingleOcurrencyPatternTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !TLSingleOcurrencyPatternTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 21:00'! testConsumeFrom | aPattern aWord anotherWord elements aPhrase aWhitespace anIndexedElement | elements := OrderedCollection new. elements add: (TLWord with: (PPToken on: 'allow')). elements add: (aWhitespace := TLWhitespace with: (PPToken on: ' ')). elements add: (TLWord with: (PPToken on: 'to')). aPhrase := TLPhrase withAll: elements. anIndexedElement := TLIndexedElement of: aPhrase. aPattern := TLSingleOcurrencyPattern of: (TLWord with: (PPToken on: 'allow')). self assert: (aPattern consumeFrom: anIndexedElement ). self assert: anIndexedElement current = aWhitespace ! ! !TLSingleOcurrencyPatternTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 20:58'! testCreation | aPattern aWord anotherWord elements aPhrase | aPattern := TLSingleOcurrencyPattern of: 1. self assert: (aPattern instVarNamed: 'element' ) = 1. ! ! TestCase subclass: #TLSomehowRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !TLSomehowRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 15:36'! testFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (aWord := TLWord with: (PPToken on: 'Somehow')). words add: (TLWord with: (PPToken on: 'truth')). words add: (TLWord with: (PPToken on: 'is')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLSomehowRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! !TLSomehowRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 15:35'! testFailureCaseInsensitive | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'THE')). words add: (aWord := TLWord with: (PPToken on: 'SOMEHOW')). 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 := TLSomehowRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! !TLSomehowRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 15:36'! testFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (aWord := TLWord with: (PPToken on: 'Somehow')). 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 := TLSomehowRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! !TLSomehowRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 15:35'! 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 := TLSomehowRule new. results := aRule runOn: aDocument. self assert: results isEmpty! ! TestCase subclass: #TLStuffRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !TLStuffRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 14:20'! testFailureCaseInsensitive | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'THE')). words add: (aWord := TLWord with: (PPToken on: 'STUFF')). 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 := TLStuffRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! !TLStuffRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 14:22'! testStuffFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (aWord := TLWord with: (PPToken on: 'Stuff')). words add: (TLWord with: (PPToken on: 'truth')). words add: (TLWord with: (PPToken on: 'is')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLStuffRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! !TLStuffRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 14:22'! testStuffFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (aWord := TLWord with: (PPToken on: 'stuff')). 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 := TLStuffRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! !TLStuffRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 14:22'! testStuffsFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (aWord := TLWord with: (PPToken on: 'Stuffs')). words add: (TLWord with: (PPToken on: 'truth')). words add: (TLWord with: (PPToken on: 'is')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLStuffRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! !TLStuffRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 14:23'! testStuffsFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (aWord := TLWord with: (PPToken on: 'stuffs')). 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 := TLStuffRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! !TLStuffRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 14:20'! 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 := TLStuffRule new. results := aRule runOn: aDocument. self assert: results isEmpty! ! TestCase subclass: #TLTerminatorMarkTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Model'! !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/9/2010 11:53'! testInterval | aToken | aToken := TLTerminatorMark with: (PPToken on: '.' start: 1 stop: 1) . self assert: aToken interval size = 1! ! !TLTerminatorMarkTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 14:05'! 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. self deny: aToken isPhrase.! ! !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-Tests-Runner'! !TLTextLintCheckerTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 15:38'! testCheckSingleRule | aChecker results| aChecker := TLTextLintChecker new. aChecker addRule: (TLALotRule new). results := aChecker check: 'test a lot that.'. self assert: ( results size = 1 ). self assert: results first element isPhrase. self assert: ( results first element text = 'a lot' ). ! ! TestCase subclass: #TLTextLintRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !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-Parser'! !TLTextParserTest methodsFor: 'utilities' stamp: 'lr 4/9/2010 11:02'! 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'. self assert: (document printString includesSubString: aString) description: 'Document print string should include its contents'. self assert: (aString copyFrom: document start to: document stop) = aString description: 'Invalid start/stop of document'. document paragraphs do: [ :each | self assert: (aString copyFrom: each start to: each stop) = each text description: 'Invalid start/stop of paragraph' ]. document sentences do: [ :each | self assert: (aString copyFrom: each start to: each stop) = each text description: 'Invalid start/stop of sentence' ]. document words do: [ :each | self assert: (aString copyFrom: each start to: each stop) = each text description: 'Invalid start/stop of word' ]. ^ document! ! !TLTextParserTest methodsFor: 'test' stamp: 'lr 4/8/2010 13:52'! testAllCharacters | document | document := self parse: (String withAll: Character allByteCharacters). self assert: document paragraphs size = 3. self assert: document sentences size = 8. self assert: document words size = 9! ! !TLTextParserTest methodsFor: 'test' stamp: 'lr 4/8/2010 13:46'! testDeformedParagraphs | document | document := self parse: 'text1 text2'. self assert: document paragraphs size = 2. self assert: document sentences size = 2. self assert: document words size = 2. self assert: document words first text = 'text1'. self assert: document words second text = 'text2'! ! !TLTextParserTest methodsFor: 'test' stamp: 'lr 4/8/2010 13:48'! testLongParagraph | document | document := self parse: 'A conventional language and development environment should be leveraged as the host instead of introducing a new or derived one. Furthermore embedded languages should not suffer from an additional interpretation layer, but instead run at the same level as the host language. This avoids compatibility problem with existing code, and performance impact of embedded code.'. self assert: document paragraphs size = 1. self assert: document sentences size = 3. self assert: document words size = 55. self assert: document words first text = 'A'. self assert: document words last text = 'code'! ! !TLTextParserTest methodsFor: 'test' stamp: 'lr 4/8/2010 13:49'! testSimpleSentence | 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-Tests-Rules'! !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/8/2010 13:37'! testFailureCaseInsensitive | 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-Tests-Rules'! !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/8/2010 13:37'! testFailureCaseInsensitive | 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-Tests-Rules'! !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/8/2010 13:32'! testFailureCaseInsensitive | 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: #TLThingRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !TLThingRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 14:15'! testFailureCaseInsensitive | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'THE')). words add: (aWord := TLWord with: (PPToken on: 'THING')). 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 := TLThingRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! !TLThingRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 14:20'! 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 := TLThingRule new. results := aRule runOn: aDocument. self assert: results isEmpty! ! !TLThingRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 14:23'! testThingFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (aWord := TLWord with: (PPToken on: 'Thing')). words add: (TLWord with: (PPToken on: 'truth')). words add: (TLWord with: (PPToken on: 'is')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLThingRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! !TLThingRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 14:16'! testThingFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (aWord := TLWord with: (PPToken on: 'thing')). 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 := TLThingRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! !TLThingRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 14:23'! testThingsFailure | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (aWord := TLWord with: (PPToken on: 'Things')). words add: (TLWord with: (PPToken on: 'truth')). words add: (TLWord with: (PPToken on: 'is')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLThingRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! !TLThingRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/8/2010 14:16'! testThingsFailureInSentence | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (aWord := TLWord with: (PPToken on: 'things')). 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 := TLThingRule new. results := aRule runOn: aDocument. self assert: results size = 1. self assert: results first = aWord. ! ! TestCase subclass: #TLWhitespaceTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Model'! !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/9/2010 11:53'! testInterval | aToken | aToken := TLWhitespace with: (PPToken on: ' ' start: 1 stop: 1) . self assert: aToken interval size = 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/9/2010 14:05'! 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. self deny: aToken isPhrase.! ! !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: #TLWordRepetitionInParagraphRuleTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Rules'! !TLWordRepetitionInParagraphRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 11:11'! testFailureSingleParagraph | aRule aWord aDocument anotherWord aSentence words sentences aParagraph paragraphs results word1 word2 word3 | words := OrderedCollection new. words add: (word1 := TLWord with: (PPToken on: 'test')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (TLWord with: (PPToken on: 'lot')). words add: (word2 := TLWord with: (PPToken on: 'test')). words add: (word3 :=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 := TLWordRepetitionInParagraphRule new. results := aRule runOn: aDocument. self assert: results size = 3. self assert: results first = word1. self assert: results second = word2. self assert: results last = word3. ! ! !TLWordRepetitionInParagraphRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 11:16'! testFailureTwoParagraph | aRule aWord aDocument anotherWord aSentence words sentences aParagraph anotherParagraph paragraphs results word1 word2 word3 word4 word5 word6 | words := OrderedCollection new. words add: (word1 := TLWord with: (PPToken on: 'test')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (TLWord with: (PPToken on: 'lot')). words add: (word2 := TLWord with: (PPToken on: 'test')). words add: (word3 := TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. words := OrderedCollection new. words add: (word4 := TLWord with: (PPToken on: 'test')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (TLWord with: (PPToken on: 'lot')). words add: (word5 := TLWord with: (PPToken on: 'test')). words add: (word6 := TLWord with: (PPToken on: 'test')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. anotherParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph with: anotherParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLWordRepetitionInParagraphRule new. results := aRule runOn: aDocument. self assert: results size = 6. self assert: results first = word1. self assert: results second = word2. self assert: results third = word3. self assert: results fourth = word4. self assert: results fifth = word5. self assert: results sixth = word6. ! ! !TLWordRepetitionInParagraphRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 11:02'! 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: 'lot')). 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 := TLWordRepetitionInParagraphRule new. results := aRule runOn: aDocument. self assert: results isEmpty. ! ! !TLWordRepetitionInParagraphRuleTest methodsFor: 'test' stamp: 'JorgeRessia 4/12/2010 11:21'! testSuccessInTwoParagraphs | aRule aWord aDocument anotherWord aSentence words sentences aParagraph anotherParagraph paragraphs results | words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (TLWord with: (PPToken on: 'lot')). words add: (TLWord with: (PPToken on: 'test')). words add: (TLWord with: (PPToken on: 'test1')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. aParagraph := TLParagraph withAll: sentences. words := OrderedCollection new. words add: (TLWord with: (PPToken on: 'test')). words add: (TLWhitespace with: (PPToken on: ' ')). words add: (TLWord with: (PPToken on: 'lot')). words add: (TLWord with: (PPToken on: 'test1')). words add: (TLWord with: (PPToken on: 'test1')). aSentence := TLSentence withAll: words. sentences := OrderedCollection with: aSentence. anotherParagraph := TLParagraph withAll: sentences. paragraphs := OrderedCollection with: aParagraph with: anotherParagraph. aDocument := TLDocument withAll: paragraphs. aRule := TLWordRepetitionInParagraphRule new. results := aRule runOn: aDocument. self assert: results isEmpty. ! ! TestCase subclass: #TLWordTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests-Model'! !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/9/2010 11:51'! testInterval | aWord | aWord := TLWord with: (PPToken on: '1' start: 1 stop: 1) . self assert: aWord interval size = 1! ! !TLWordTest methodsFor: 'test' stamp: 'JorgeRessia 4/9/2010 14:06'! 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. self deny: aWord isPhrase.! ! !TLWordTest methodsFor: 'test' stamp: 'JorgeRessia 4/7/2010 12:01'! testText | aWord | aWord := TLWord with: (PPToken on: '1') . self assert: aWord text = '1'! !