-
Notifications
You must be signed in to change notification settings - Fork 68
/
SlangTypeForDereferenceTest.class.st
70 lines (57 loc) · 2.55 KB
/
SlangTypeForDereferenceTest.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Class {
#name : #SlangTypeForDereferenceTest,
#superclass : #SlangAbstractTestCase,
#category : #'Slang-Tests'
}
{ #category : #running }
SlangTypeForDereferenceTest >> setUp [
super setUp.
ccg addClass: SlangTypeForDereferenceTestClass.
ccg inferTypes.
]
{ #category : #tests }
SlangTypeForDereferenceTest >> testAtOnArray [
| tMethod |
tMethod := ccg methodNamed: #aMethodReturningAnAtOnAnArray.
self assert: tMethod isNotNil.
self assert: (ccg typeFor: tMethod statements first expression in: tMethod) equals: #int."at: node"
self assert: (ccg typeFor: tMethod statements first in: tMethod) equals: #int."returnNode"
self assertReturnTypeOf: tMethod equalsHarmonized: #int
]
{ #category : #tests }
SlangTypeForDereferenceTest >> testAtOnMatrix [
| tMethod |
tMethod := ccg methodNamed: #aMethodReturningAnAtOnAMatrix.
self assert: tMethod isNotNil.
self assert: (ccg typeFor: tMethod statements first expression in: tMethod) equals: #'int *'."at: node"
self assert: (ccg typeFor: tMethod statements first in: tMethod) equals: #'int *'."returnNode"
self assert: tMethod returnType equals: #'int *'.
]
{ #category : #tests }
SlangTypeForDereferenceTest >> testReturnPointerTypeExplicitTempVariable [
| tMethod |
tMethod := ccg methodNamed: #aMethodReturningAPointerType.
self assert: tMethod isNotNil.
self assert: (ccg typeFor: tMethod statements first expression in: tMethod) equals: #'int *'."variable node"
self assert: (ccg typeFor: tMethod statements first in: tMethod) equals: #'int *'."return node"
self assert: tMethod returnType equals: #'int *'
]
{ #category : #tests }
SlangTypeForDereferenceTest >> testSelfMessageReturningPointerType [
| tMethod |
tMethod := ccg methodNamed: #aMethodReturningAPointerType.
self assert: tMethod isNotNil.
self assert: (ccg typeFor: tMethod statements first expression in: tMethod) equals: #'int *'."message node"
self assert: (ccg typeFor: tMethod statements first in: tMethod) equals: #'int *'."returnNode"
self assert: tMethod returnType equals: #'int *'
]
{ #category : #tests }
SlangTypeForDereferenceTest >> testTwoAtOnMatrix [
| tMethod |
tMethod := ccg methodNamed: #aMethodReturningTwoAtOnAMatrix.
self assert: tMethod isNotNil.
self assert: (ccg typeFor: tMethod statements first expression receiver in: tMethod) equals: #'int *'."inner at:"
self assert: (ccg typeFor: tMethod statements first expression in: tMethod) equals: #int."outer at:"
self assert: (ccg typeFor: tMethod statements first in: tMethod) equals: #int."return node"
self assertReturnTypeOf: tMethod equalsHarmonized: #int
]