-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from moosetechnology/local-resolver
Local resolver
- Loading branch information
Showing
6 changed files
with
287 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
src/FAST-Core-Tools-Tests/FASTLocalResolverScopingTest.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
" | ||
A FASTLocalResolverScopingTest is a test class for testing the behavior of FASTLocalResolverScoping | ||
" | ||
Class { | ||
#name : #FASTLocalResolverScopingTest, | ||
#superclass : #TestCase, | ||
#instVars : [ | ||
'resolverScoping' | ||
], | ||
#category : #'FAST-Core-Tools-Tests-Resolver' | ||
} | ||
|
||
{ #category : #running } | ||
FASTLocalResolverScopingTest >> setUp [ | ||
super setUp. | ||
|
||
resolverScoping := FASTLocalResolverScoping new | ||
] | ||
|
||
{ #category : #tests } | ||
FASTLocalResolverScopingTest >> testAddNonLocalDeclaration [ | ||
"testing helper method #addNonLocalDeclaration:" | ||
resolverScoping resetScopes. | ||
resolverScoping pushScope. | ||
|
||
resolverScoping scopeAddNonLocalDeclaration: 'blah'. | ||
|
||
"second scope is empty" | ||
self assert: resolverScoping popScope isEmpty. | ||
|
||
"first scope contains NonLocalDeclaration" | ||
self assert: (resolverScoping findDeclaration: 'blah') class equals: FASTNonLocalDeclaration | ||
] | ||
|
||
{ #category : #tests } | ||
FASTLocalResolverScopingTest >> testFindDeclarationInCurrentScope [ | ||
|node| | ||
node := FASTEntity new. | ||
resolverScoping resetScopes. | ||
resolverScoping scopeAdd: 'blah' declaration: node. | ||
|
||
self assert: (resolverScoping findDeclaration: 'blah') equals: node | ||
] | ||
|
||
{ #category : #tests } | ||
FASTLocalResolverScopingTest >> testFindDeclarationInEmptyScope [ | ||
resolverScoping resetScopes. | ||
self assert: (resolverScoping findDeclaration: 'blah') equals: nil. | ||
|
||
] | ||
|
||
{ #category : #tests } | ||
FASTLocalResolverScopingTest >> testFindDeclarationInParentScope [ | ||
|node| | ||
node := FASTEntity new. | ||
resolverScoping resetScopes. | ||
resolverScoping scopeAdd: 'blah' declaration: node. | ||
resolverScoping pushScope. | ||
|
||
self assert: (resolverScoping findDeclaration: 'blah') equals: node | ||
] | ||
|
||
{ #category : #tests } | ||
FASTLocalResolverScopingTest >> testFindDeclarationNotInScope [ | ||
|node| | ||
node := FASTEntity new. | ||
resolverScoping resetScopes. | ||
resolverScoping scopeAdd: 'blah' declaration: node. | ||
|
||
self assert: (resolverScoping findDeclaration: 'blih') equals: nil. | ||
|
||
] | ||
|
||
{ #category : #tests } | ||
FASTLocalResolverScopingTest >> testHasScopes [ | ||
"initialization creates a scope" | ||
|
||
self assert: resolverScoping hasScopes | ||
] | ||
|
||
{ #category : #tests } | ||
FASTLocalResolverScopingTest >> testLocalDeclarationFor [ | ||
"testing helper method #localDeclaration:for:" | ||
| declNode refNode | | ||
declNode := FASTEntity new. | ||
refNode := FASTEntity new. | ||
declNode resetLocalUses. | ||
resolverScoping localDeclaration: declNode for: refNode. | ||
|
||
self assert: refNode localDeclaration notNil. | ||
self assert: refNode localDeclaration equals: declNode. | ||
|
||
self assert: declNode localUses size equals: 1. | ||
self assert: declNode localUses first equals: refNode | ||
] | ||
|
||
{ #category : #tests } | ||
FASTLocalResolverScopingTest >> testResetScopes [ | ||
resolverScoping resetScopes. | ||
self assert: resolverScoping hasScopes. | ||
|
||
] | ||
|
||
{ #category : #tests } | ||
FASTLocalResolverScopingTest >> testScopeAddDeclarationTwiceRaisesError [ | ||
|node| | ||
node := FASTEntity new. | ||
resolverScoping resetScopes. | ||
|
||
resolverScoping scopeAdd: 'blah' declaration: node. | ||
|
||
self assert: resolverScoping currentScope size equals: 1. | ||
|
||
self | ||
should: [ resolverScoping scopeAdd: 'blah' declaration: node ] | ||
raise: DuplicatedVariableError | ||
] | ||
|
||
{ #category : #tests } | ||
FASTLocalResolverScopingTest >> testScopeAddNonLocalDeclarationTwiceRaisesError [ | ||
|node| | ||
node := FASTEntity new. | ||
resolverScoping resetScopes. | ||
|
||
resolverScoping scopeAddNonLocalDeclaration: 'blah'. | ||
|
||
self assert: resolverScoping currentScope size equals: 1. | ||
|
||
self | ||
should: [ resolverScoping scopeAddNonLocalDeclaration: 'blah' ] | ||
raise: DuplicatedVariableError | ||
] |
131 changes: 0 additions & 131 deletions
131
src/FAST-Core-Tools-Tests/FASTLocalResolverVisitorTest.class.st
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.