-
Notifications
You must be signed in to change notification settings - Fork 65
/
StackInterpreterSimulatorTests.class.st
112 lines (101 loc) · 3.71 KB
/
StackInterpreterSimulatorTests.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
Class {
#name : #StackInterpreterSimulatorTests,
#superclass : #TestCase,
#category : #'VMMaker-OriginalTests'
}
{ #category : #tests }
StackInterpreterSimulatorTests >> testEmptySimulatorCanCloneSimulation [
self shouldnt:
[(StackInterpreterSimulator newWithOptions: #(ObjectMemory Spur32BitMemoryManager))
cloneSimulation cloneSimulation]
raise: Error
]
{ #category : #tests }
StackInterpreterSimulatorTests >> testEmptySimulatorCloneCanLoadImage [
self shouldnt:
[(StackInterpreterSimulator newWithOptions: #(ObjectMemory Spur32BitMemoryManager))
cloneSimulation
openOn: SpurImageTestResource imageNameForTests extraMemory: 0]
raise: Error
]
{ #category : #tests }
StackInterpreterSimulatorTests >> testHackBits [
"Test that the hackBits plumbing, used for display update in the
simulated ioShow:D:i:s:p:l:a:y:, works for the underlying memory classes."
| mem32 mem64 disp32 disp64 hack32 hack64 |
mem32 := LittleEndianBitmap new: 65536 / 4.
mem64 := DoubleWordArray new: 65536 / 8.
1 to: 65536 by: 8 do:
[:i|
mem32
unsignedLong64At: i
put: ((i // 8) even
ifTrue: [16r5555555555555555]
ifFalse: [16rAAAAAAAAAAAAAAAA]).
mem64
unsignedLong64At: i
put: ((i // 8) even
ifTrue: [16r5555555555555555]
ifFalse: [16rAAAAAAAAAAAAAAAA])].
self assert: (mem32 copy changeClassTo: ByteArray) = (mem64 copy changeClassTo: ByteArray).
hack32 := Form new hackBits: mem32.
hack64 := Form new hackBits: mem64.
disp32 := Form new hackBits: (ByteArray new: 65536).
disp64 := Form new hackBits: (ByteArray new: 65536).
disp32
copy: (0 @ 0 extent: 4 @ (65536 / 4))
from: 0 @ 0
in: hack32
rule: Form over.
disp64
copy: (0 @ 0 extent: 4 @ (65536 / 4))
from: 0 @ 0
in: hack64
rule: Form over.
1 to: 65536 by: 8 do:
[:i|
self assert: ((i // 8) even
ifTrue: [16r5555555555555555]
ifFalse: [16rAAAAAAAAAAAAAAAA])
equals: (disp32 bits unsignedLong64At: i).
self assert: ((i // 8) even
ifTrue: [16r5555555555555555]
ifFalse: [16rAAAAAAAAAAAAAAAA])
equals: (disp64 bits unsignedLong64At: i)]
]
{ #category : #tests }
StackInterpreterSimulatorTests >> testPluginSimulators [
"Test that every plugin under InterpreterPlugin that shouldBeTranslated can also instantiate a simulator.
Test that every SmartSyntaxInterpreterPlugin is simulated via a SmartSyntaxPluginSimulator."
| simulatablePlugins objectMemory vm |
vm := StackInterpreterSimulator newWithOptions: #(ObjectMemory Spur32BitMemoryManager).
objectMemory := vm objectMemory.
simulatablePlugins := InterpreterPlugin allSubclasses select:
[:pc| pc shouldBeTranslated and: [pc simulatorClass notNil]].
simulatablePlugins do:
[:pc|
self shouldnt: [self assert: (pc simulatorForInterpreterInterface: objectMemory) notNil]
raise: Error].
simulatablePlugins := SmartSyntaxInterpreterPlugin allSubclasses select:
[:pc| pc shouldBeTranslated and: [pc simulatorClass notNil]].
simulatablePlugins do:
[:pc|
self shouldnt:
[| simulator |
simulator := pc simulatorForInterpreterInterface: objectMemory.
self assert: simulator class == SmartSyntaxPluginSimulator.
pc simulatorClass ifNotNil:
[:simulatorClass|
simulatorClass == SmartSyntaxPluginSimulator
ifTrue: [self assert: (simulator actualPlugin isKindOf: pc)]
ifFalse: [self assert: simulator actualPlugin class == simulatorClass]]]
raise: Error]
]
{ #category : #tests }
StackInterpreterSimulatorTests >> testSimulatorCanReloadImage [
self shouldnt:
[(StackInterpreterSimulator newWithOptions: #(ObjectMemory Spur32BitMemoryManager))
openOn: SpurImageTestResource imageNameForTests extraMemory: 0;
openOn: SpurImageTestResource imageNameForTests extraMemory: 0]
raise: Error
]