-
Notifications
You must be signed in to change notification settings - Fork 67
/
VMFFISameThreadCalloutTest.class.st
52 lines (36 loc) · 1.6 KB
/
VMFFISameThreadCalloutTest.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
Class {
#name : #VMFFISameThreadCalloutTest,
#superclass : #VMAbstractFFITest,
#category : #VMMakerTests
}
{ #category : #'tests - callouts' }
VMFFISameThreadCalloutTest >> testPrimitiveSameThreadCalloutMaintainsActiveProcess [
| parametersArray tfExternalFunction oldActiveProcess |
tfExternalFunction := self createReturnFloatExternalFunctionFor: [ 7.0 ].
oldActiveProcess := interpreter activeProcess.
parametersArray := self newArrayWithSlots: 0.
interpreter push: memory nilObject.
interpreter push: tfExternalFunction.
interpreter push: parametersArray.
interpreter argumentCount: 2.
interpreter primitiveSameThreadCallout.
self assert: interpreter activeProcess equals: oldActiveProcess
]
{ #category : #'tests - callouts' }
VMFFISameThreadCalloutTest >> testPrimitiveSameThreadCalloutShouldKeepTheNewMethodVariable [
| parametersArray tfExternalFunction oldActiveProcess callbackContext |
callbackContext := VMCallbackContext new.
callbackContext trampoline: ExitInterpreter new.
tfExternalFunction := self createReturnFloatExternalFunctionFor: [
[interpreter ptEnterInterpreterFromCallback: callbackContext]
on: ExitInterpreter do: [ 3.14 ] ].
oldActiveProcess := interpreter activeProcess.
parametersArray := self newArrayWithSlots: 0.
interpreter push: memory nilObject.
interpreter push: tfExternalFunction.
interpreter push: parametersArray.
interpreter interpreteBlock: [ interpreter ptExitInterpreterToCallback: callbackContext ].
interpreter argumentCount: 2.
interpreter primitiveSameThreadCallout.
self assert: interpreter activeProcess equals: oldActiveProcess.
]