SystemOrganization addCategory: #'ShoutTests-Parsing'! TestCase subclass: #SHParserST80Test instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'ShoutTests-Parsing'! !SHParserST80Test methodsFor: 'tests-manual' stamp: 'tween 7/8/2006 16:43'! d "ensure that d is defined so that we don't get an #undefinedUnary token type "! ! !SHParserST80Test methodsFor: 'tests-manual' stamp: 'tween 7/8/2006 12:02'! e "ensure that e is defined so that we don't get an #undefinedUnary token type "! ! !SHParserST80Test methodsFor: 'tests-manual' stamp: 'tween 7/8/2006 12:02'! q "ensure that q is defined so that we don't get an #undefinedUnary token type "! ! !SHParserST80Test methodsFor: 'tests-manual' stamp: 'tween 7/8/2006 12:02'! r "ensure that r is defined so that we don't get an #undefinedUnary token type "! ! !SHParserST80Test methodsFor: 'tests-manual' stamp: 'tween 7/8/2006 12:02'! s "ensure that s is defined so that we don't get an #undefinedUnary token type "! ! !SHParserST80Test methodsFor: 'tests-smoke' stamp: 'lr 10/18/2010 15:33'! testBooleanHierarchy self verifyHierarchy: Boolean! ! !SHParserST80Test methodsFor: 'tests-smoke' stamp: 'lr 10/18/2010 15:24'! testCollectionHierarchy self verifyHierarchy: Collection! ! !SHParserST80Test methodsFor: 'tests-smoke' stamp: 'lr 10/18/2010 15:24'! testNumberHierarchy self verifyHierarchy: Number! ! !SHParserST80Test methodsFor: 'tests' stamp: 'lr 10/18/2010 15:19'! testNumbers | types tokens s | s := 'x 1'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '1'). s := 'x -1'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary #- number). self assert: tokens = #('x' '-' '1'). s := 'x -1.1'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary #- number). self assert: tokens = #('x' '-' '1.1'). s := 'x -1.1.'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary #- number statementSeparator). self assert: tokens = #('x' '-' '1.1' '.'). s := 'x 1.true'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number statementSeparator #true). self assert: tokens = #('x' '1' '.' 'true'). s := 'x 2r1'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '2r1'). s := 'x 2d1'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '2d1'). s := 'x 2e1'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '2e1'). s := 'x 2q1'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '2q1'). s := 'x 16r-A'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '16r-A'). s := 'x -16r-A'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary #- number). self assert: tokens = #('x' '-' '16r-A'). s := 'x 16r'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '16r'). s := 'x 16r-'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '16r-'). s := 'x 16r-d'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '16r-d'). s := 'x 2r2'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number excessCode). self assert: tokens = #('x' '2r' '2'). s := 'x 1.'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number statementSeparator). self assert: tokens = #('x' '1' '.'). s := 'x 1yourself'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number unary). self assert: tokens = #('x' '1' 'yourself'). s := 'x 1s'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number unary). self assert: tokens = #('x' '1' 's'). s := 'x 1.1s'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number unary). self assert: tokens = #('x' '1.1' 's'). s := 'x 2r1e26'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '2r1e26'). s := 'x 16r1e-26'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number binary number). self assert: tokens = #('x' '16r1e' '-' '26'). s := 'x 16r1e'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '16r1e'). s := 'x 16r1e-1'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number binary number). self assert: tokens = #('x' '16r1e' '-' '1'). s := 'x 16r1e-'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number binary excessCode). self assert: tokens = #('x' '16r1e' '-' ''). s := 'x 16r1.ABe20'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '16r1.ABe20'). s := 'x 16r1.ABe-20'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number binary number). self assert: tokens = #('x' '16r1.ABe' '-' '20'). s := 'x 1.0e14'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '1.0e14'). s := 'x 1.0e-14'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '1.0e-14'). s := 'x 1.0e14e'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number unary). self assert: tokens = #('x' '1.0e14' 'e'). "" s := 'x 2r1q26'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '2r1q26'). s := 'x 16r1q-26'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '16r1q-26'). s := 'x 16r1q'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number unary). self assert: tokens = #('x' '16r1' 'q'). s := 'x 16r1q-1'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '16r1q-1'). s := 'x 16r1q-'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number unary binary excessCode). self assert: tokens = #('x' '16r1' 'q' '-' ''). s := 'x 16r1.ABq20'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '16r1.ABq20'). s := 'x 16r1.ABq-20'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '16r1.ABq-20'). s := 'x 1.0q14'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '1.0q14'). s := 'x 1.0q-14'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '1.0q-14'). s := 'x 1.0q14q'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number unary). self assert: tokens = #('x' '1.0q14' 'q'). "" s := 'x 2r1d26'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '2r1d26'). s := 'x 16r1d-26'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number binary number). self assert: tokens = #('x' '16r1d' '-' '26'). s := 'x 16r1d'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '16r1d'). s := 'x 16r1d-1'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number binary number). self assert: tokens = #('x' '16r1d' '-' '1'). s := 'x 16r1d-'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number binary excessCode). self assert: tokens = #('x' '16r1d' '-' ''). s := 'x 16r1.ABd20'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '16r1.ABd20'). s := 'x 16r1.ABd-20'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number binary number). self assert: tokens = #('x' '16r1.ABd' '-' '20'). s := 'x 1.0d14'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '1.0d14'). s := 'x 1.0d-14'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number). self assert: tokens = #('x' '1.0d-14'). s := 'x 1.0d14d'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number unary). self assert: tokens = #('x' '1.0d14' 'd'). "" s := 'x -1.1e-2'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary #- number ). self assert: tokens = #('x' '-' '1.1e-2'). "only first - is separate token !!" s := 'x -16r-1.0e-2'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary #- number binary number). self assert: tokens = #('x' '-' '16r-1.0e' '-' '2'). "only first - is separate token !!" s := 'x 1-1'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number binary number ). self assert: tokens = #('x' '1' '-' '1'). s := 'x 1--1'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number incompleteBinary number ). self assert: tokens = #('x' '1' '--' '1'). s := 'x 1--"comment"1'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number incompleteBinary comment number ). self assert: tokens = #('x' '1' '--' '"comment"' '1'). s := 'x 1-self'. types := self tokenTypesIn: s. tokens := self tokensIn: s. self assert: types = #(patternUnary number binary self ). self assert: tokens = #('x' '1' '-' 'self'). ! ! !SHParserST80Test methodsFor: 'tests-smoke' stamp: 'lr 10/18/2010 15:34'! testObjectClass self verifyClass: Object! ! !SHParserST80Test methodsFor: 'utilities' stamp: 'tween 7/8/2006 11:45'! tokenTypesIn: aString | parser ranges | parser := SHParserST80 new. ranges := parser rangesIn: aString classOrMetaClass: Object workspace: nil environment: nil. ^ranges asArray collect: [:each | each type]! ! !SHParserST80Test methodsFor: 'utilities' stamp: 'tween 7/8/2006 11:44'! tokensIn: aString | parser ranges | parser := SHParserST80 new. ranges := parser rangesIn: aString classOrMetaClass: Object workspace: nil environment: nil. ^ranges asArray collect: [:each | aString copyFrom: each start to: each end]! ! !SHParserST80Test methodsFor: 'utilities' stamp: 'lr 11/17/2010 15:59'! types ^ #(#'$' #- #ansiAssignment #argument #arrayEnd #arrayEnd1 #arrayStart #arrayStart1 #assignment #binary #blockArg #blockArgColon #blockArgsBar #blockEnd #blockEnd1 #blockEnd2 #blockEnd3 #blockEnd4 #blockEnd5 #blockEnd6 #blockEnd7 #blockPatternArg #blockPatternTempVar #blockStart #blockStart1 #blockStart2 #blockStart3 #blockStart4 #blockStart5 #blockStart6 #blockStart7 #blockTempBar #blockTempVar #byteArrayEnd #byteArrayEnd1 #byteArrayStart #byteArrayStart1 #cascadeSeparator #character #classVar #comment #default #excessCode #externalCallType #externalCallTypePointerIndicator #externalFunctionCallingConvention #false #globalVar #incompleteBinary #incompleteIdentifier #incompleteKeyword #incompleteUnary #instVar #integer #invalid #keyword #leftBrace #leftParenthesis #leftParenthesis1 #leftParenthesis2 #leftParenthesis3 #leftParenthesis4 #leftParenthesis5 #leftParenthesis6 #leftParenthesis7 #literal #literalArray #methodArg #methodTempBar #module #nil #number #patternArg #patternBinary #patternKeyword #patternTempVar #patternUnary #poolConstant #pragmaBinary #pragmaKeyword #pragmaUnary #primitive #primitiveOrExternalCallEnd #primitiveOrExternalCallStart #return #rightBrace #rightParenthesis #rightParenthesis1 #rightParenthesis2 #rightParenthesis3 #rightParenthesis4 #rightParenthesis5 #rightParenthesis6 #rightParenthesis7 #self #statementSeparator #string #stringSymbol #super #symbol #tempVar #thisContext #true #unary #undefinedBinary #undefinedIdentifier #undefinedKeyword #undefinedUnary #unfinishedComment #unfinishedString #workspaceVar)! ! !SHParserST80Test methodsFor: 'utilities' stamp: 'lr 10/18/2010 15:22'! verifyClass: aBehavior aBehavior selectors do: [ :selector | self verifyClass: aBehavior selector: selector ] ! ! !SHParserST80Test methodsFor: 'utilities' stamp: 'lr 11/17/2010 15:58'! verifyClass: aBehavior selector: aSymbol | ranges position types errors | ranges := SHParserST80 new rangesIn: (aBehavior sourceCodeAt: aSymbol) classOrMetaClass: aBehavior workspace: nil environment: nil. types := self types asIdentitySet. errors := #(#excessCode #unfinishedComment #unfinishedString) asIdentitySet. position := 0. ranges do: [ :each | self assert: 1 <= each length description: 'empty range'. self assert: position <= each start description: 'overlapping range'. self assert: each start <= each end description: 'empty range'. self assert: (types includes: each type) description: 'unknown type ' , each type. self deny: (errors includes: each type) description: 'error type ' , each type. position := each end ]! ! !SHParserST80Test methodsFor: 'utilities' stamp: 'lr 10/18/2010 15:21'! verifyHierarchy: aBehavior aBehavior withAllSubclassesDo: [ :class | self verifyClass: class; verifyClass: class class ]! !