/
OCASTSpecialLiteralTranslatorTest.class.st
48 lines (34 loc) · 1.57 KB
/
OCASTSpecialLiteralTranslatorTest.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Class {
#name : #OCASTSpecialLiteralTranslatorTest,
#superclass : #OCASTTranslatorTest,
#category : #'OpalCompiler-Tests-AST'
}
{ #category : #'testing - literals' }
OCASTSpecialLiteralTranslatorTest >> testDynamicLiteralArrayIsNotInLiteralFrame [
| aCompiledMethod array |
aCompiledMethod := self compileExample: #examplePushDynamicLiteralArray.
array := self executeMethodOnInstance: aCompiledMethod.
self deny: (aCompiledMethod literals identityIncludes: array).
]
{ #category : #'testing - literals' }
OCASTSpecialLiteralTranslatorTest >> testDynamicLiteralArrayReturnsAlwaysNewArray [
| aCompiledMethod |
aCompiledMethod := self compileExample: #examplePushDynamicLiteralArray.
self assert: (self executeMethodOnInstance: aCompiledMethod) ~~ (self executeMethodOnInstance: aCompiledMethod)
]
{ #category : #'testing - literals' }
OCASTSpecialLiteralTranslatorTest >> testDynamicLiteralArrayReturnsArray [
self assert: (self testExample: #examplePushDynamicLiteralArray) equals: #(1 3)
]
{ #category : #'testing - literals' }
OCASTSpecialLiteralTranslatorTest >> testDynamicLiteralArrayReturnsEqualsArray [
| aCompiledMethod |
aCompiledMethod := self compileExample: #examplePushDynamicLiteralArray.
self assert: (self executeMethodOnInstance: aCompiledMethod) equals: (self executeMethodOnInstance: aCompiledMethod)
]
{ #category : #'testing - literals' }
OCASTSpecialLiteralTranslatorTest >> testSpecialLiteralsNotInLiteralFrame [
self testExample: #examplePushNonSpecialSmallInteger.
self assert: instance result equals: 10.
self assert: (method hasLiteral: 10)
]