-
-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First (and failing) test for the FullBlockClosure bc->AST mapping
- Loading branch information
1 parent
1a76c75
commit 8276b71
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/OpalCompiler-Tests/OCASTTranslatorMappingForFullBlockClosuresTest.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,46 @@ | ||
Class { | ||
#name : #OCASTTranslatorMappingForFullBlockClosuresTest, | ||
#superclass : #TestCase, | ||
#instVars : [ | ||
'ctx', | ||
'compiler' | ||
], | ||
#category : #'OpalCompiler-Tests-AST' | ||
} | ||
|
||
{ #category : #testing } | ||
OCASTTranslatorMappingForFullBlockClosuresTest >> assertBlockNodeHasCorrectIR: blockNode [ | ||
| sequence | | ||
blockNode methodNode ir. | ||
sequence := blockNode ir startSequence. | ||
self assert: (sequence allSatisfy: [ :ir | ir sourceNode notNil ]). | ||
self assert: sequence last equals: blockNode body | ||
] | ||
|
||
{ #category : #support } | ||
OCASTTranslatorMappingForFullBlockClosuresTest >> compileSourceToMethod: source [ | ||
| method | | ||
method := compiler | ||
source: source; | ||
compile. | ||
method ast compilationContext: ctx. | ||
^ method | ||
] | ||
|
||
{ #category : #running } | ||
OCASTTranslatorMappingForFullBlockClosuresTest >> setUp [ | ||
ctx := CompilationContext new | ||
encoderClass: EncoderForSistaV1; | ||
setOptions: {#optionFullBlockClosure . #optionEmbeddSources} asSet. | ||
compiler := OpalCompiler new | ||
compilationContext: ctx; | ||
yourself | ||
] | ||
|
||
{ #category : #testing } | ||
OCASTTranslatorMappingForFullBlockClosuresTest >> testSimpleBlockASTMapping [ | ||
|method blockNode| | ||
method := self compileSourceToMethod: 'm [1 + 2]'. | ||
blockNode := method ast statements first. | ||
self assertBlockNodeHasCorrectIR: blockNode | ||
] |