Skip to content

Commit

Permalink
First (and failing) test for the FullBlockClosure bc->AST mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenCostiou committed Aug 6, 2019
1 parent 1a76c75 commit 8276b71
Showing 1 changed file with 46 additions and 0 deletions.
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
]

0 comments on commit 8276b71

Please sign in to comment.