Skip to content

Commit

Permalink
OCBytecodeToASTCacheTest had some tests that tested against the old i…
Browse files Browse the repository at this point in the history
…mplementation. As we replaced this with the cache, we need to rewite the tests to compare something else (e.g which kind of node)
  • Loading branch information
MarcusDenker committed Apr 27, 2020
1 parent c586cdd commit 36f6828
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/OpalCompiler-Tests/OCBytecodeToASTCacheTest.class.st
Expand Up @@ -36,9 +36,10 @@ OCBytecodeToASTCacheTest >> testFirstBCOffsetTest [
OCBytecodeToASTCacheTest >> testHigherThanLastBCOffsetAccessTest [
| pc |
pc := cache lastBcOffset + 5.
"if we are beyond the last bc, we map to the whole method"
self
assert: (cache nodeForPC: pc)
identicalTo: (compiledMethod sourceNodeForPC: pc)
identicalTo: compiledMethod ast
]

{ #category : #tests }
Expand All @@ -60,21 +61,17 @@ OCBytecodeToASTCacheTest >> testLowerThanFirstBCOffsetAccessTest [
{ #category : #tests }
OCBytecodeToASTCacheTest >> testNodeForBCOffsetRangeTest [
"As we associate each node to each possible bytecode offset that can refer to it,
we have to check that associations are consistent between a range and a node"
we have to check that associations are all pointing to a node"

| pcRange |
pcRange := 0 to: cache lastBcOffset.
pcRange do: [ :pc |
self
assert: (cache nodeForPC: pc)
identicalTo: (compiledMethod sourceNodeForPC: pc) ]
pcRange do: [ :pc | self assert: ((cache nodeForPC: pc) isKindOf: RBProgramNode)]
]

{ #category : #tests }
OCBytecodeToASTCacheTest >> testNodeForBCOffsetTest [
| pc |
"there should be an assignment at pc 51"
pc := 51.
self
assert: (cache nodeForPC: pc)
identicalTo: (compiledMethod sourceNodeForPC: pc)
self assert: (cache nodeForPC: pc) isAssignment
]

0 comments on commit 36f6828

Please sign in to comment.