Skip to content

Commit

Permalink
Merge pull request #128 from guillep/fix-tests
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
guillep authored Mar 17, 2024
2 parents 5a663b2 + cde4088 commit 6f8878a
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Druid-Tests/DRInterpreterCompilationUnitTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ DRInterpreterCompilationUnitTest >> primitiveMethod [
{ #category : #'object access' }
DRInterpreterCompilationUnitTest >> targetClass [

^ DruidTestRTLCompiler
^ DruidTestRTLCompilerForTest
]

{ #category : #'tests - bytecodes' }
Expand Down
98 changes: 78 additions & 20 deletions Druid-Tests/DRProductionPrimitiveCompilationTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,30 @@ DRProductionPrimitiveCompilationTest >> setUp [
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveAt [

| class array |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveAt.

class := self newClassInOldSpaceWithSlots: 0 instSpec: memory arrayFormat.
class := self
newClassInOldSpaceWithSlots: 0
instSpec: memory arrayFormat.
array := memory instantiateClass: class indexableSize: 1.
memory storePointer: 0 ofObject: array withValue: 42.

self executePrimitiveWithReceiver: array
withArguments: { memory integerObjectOf: 1 }.

self
executePrimitiveWithReceiver: array
withArguments: { (memory integerObjectOf: 1) }.

self assert: machineSimulator receiverRegisterValue equals: 42

]

{ #category : #'tests-real primitives' }
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveAtByteArray [

| array |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveAt.

Expand All @@ -61,6 +67,8 @@ DRProductionPrimitiveCompilationTest >> testCompilePrimitiveAtByteArray [
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveAtContext [

| context |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveAt.

Expand All @@ -78,44 +86,64 @@ DRProductionPrimitiveCompilationTest >> testCompilePrimitiveAtContext [
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveAtFaillingWithNegativeIndex [

| class array |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveAt.

class := self newClassInOldSpaceWithSlots: 0 instSpec: memory arrayFormat.
class := self
newClassInOldSpaceWithSlots: 0
instSpec: memory arrayFormat.
array := memory instantiateClass: class indexableSize: 1.

self executeUntilStopPrimitiveWithReceiver: array withArguments: { memory integerObjectOf: -2 }
self
executeUntilStopPrimitiveWithReceiver: array
withArguments: { (memory integerObjectOf: -2) }
]

{ #category : #'tests-real primitives' }
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveAtFaillingWithOverflowIndex [

| class array |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveAt.

class := self newClassInOldSpaceWithSlots: 0 instSpec: memory arrayFormat.
class := self
newClassInOldSpaceWithSlots: 0
instSpec: memory arrayFormat.
array := memory instantiateClass: class indexableSize: 1.

self executeUntilStopPrimitiveWithReceiver: array withArguments: { memory integerObjectOf: 2 }
self
executeUntilStopPrimitiveWithReceiver: array
withArguments: { (memory integerObjectOf: 2) }
]

{ #category : #'tests-real primitives' }
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveAtFaillingWithZeroIndex [

| class array |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveAt.

class := self newClassInOldSpaceWithSlots: 0 instSpec: memory arrayFormat.
class := self
newClassInOldSpaceWithSlots: 0
instSpec: memory arrayFormat.
array := memory instantiateClass: class indexableSize: 1.

self executeUntilStopPrimitiveWithReceiver: array withArguments: { memory integerObjectOf: 0 }
self
executeUntilStopPrimitiveWithReceiver: array
withArguments: { (memory integerObjectOf: 0) }
]

{ #category : #'tests-real primitives' }
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveAtIsNotCompletePrimitive [

(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self
compileDruidPrimitiveGenerator: #primitiveAt
with: [ :c | "nothing" ].
Expand All @@ -129,32 +157,40 @@ DRProductionPrimitiveCompilationTest >> testCompilePrimitiveAtIsNotCompletePrimi
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveAtManyElements [

| class array |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveAt.

class := self newClassInOldSpaceWithSlots: 0 instSpec: memory arrayFormat.
class := self
newClassInOldSpaceWithSlots: 0
instSpec: memory arrayFormat.
array := memory instantiateClass: class indexableSize: 2.
memory storePointer: 0 ofObject: array withValue: 40.
memory storePointer: 1 ofObject: array withValue: 41.

self executePrimitiveWithReceiver: array
withArguments: { memory integerObjectOf: 2 }.

self
executePrimitiveWithReceiver: array
withArguments: { (memory integerObjectOf: 2) }.

self assert: machineSimulator receiverRegisterValue equals: 41

]

{ #category : #'tests-real primitives' }
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveAtMethod [

| class method |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveAt.

class := self newClassInOldSpaceWithSlots: 0 instSpec: memory firstCompiledMethodFormat.
class := self
newClassInOldSpaceWithSlots: 0
instSpec: memory firstCompiledMethodFormat.
method := memory
instantiateCompiledMethodClass: class
indexableSize: 10.
instantiateCompiledMethodClass: class
indexableSize: 10.

self
executeUntilStopPrimitiveWithReceiver: method
Expand All @@ -165,6 +201,8 @@ DRProductionPrimitiveCompilationTest >> testCompilePrimitiveAtMethod [
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveAtOnNonArray [

| ephemeron |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveAt.

Expand Down Expand Up @@ -313,6 +351,8 @@ DRProductionPrimitiveCompilationTest >> testCompilePrimitiveSize [
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInitializesArray [

| class |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveNewWithArg.

Expand All @@ -336,6 +376,8 @@ DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInitialize
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInitializesByteArray [

| class |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveNewWithArg.

Expand All @@ -359,6 +401,8 @@ DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInitialize
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInitializesInteger16Array [

| class |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveNewWithArg.

Expand All @@ -382,6 +426,8 @@ DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInitialize
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInitializesInteger32Array [

| class |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveNewWithArg.

Expand All @@ -405,6 +451,8 @@ DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInitialize
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInitializesInteger64Array [

| class |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveNewWithArg.

Expand All @@ -428,6 +476,8 @@ DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInitialize
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInstantiatesArray [

| class |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveNewWithArg.

Expand All @@ -437,7 +487,7 @@ DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInstantiat
memory ensureBehaviorHash: class.
self
executePrimitiveWithReceiver: class
withArguments: { memory integerObjectOf: 3 }.
withArguments: { (memory integerObjectOf: 3) }.

self
assert:
Expand All @@ -449,6 +499,8 @@ DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInstantiat
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInstantiatesByteArray [

| class |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveNewWithArg.

Expand All @@ -470,6 +522,8 @@ DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInstantiat
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInstantiatesInteger16Array [

| class |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveNewWithArg.

Expand All @@ -491,6 +545,8 @@ DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInstantiat
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInstantiatesInteger32Array [

| class |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveNewWithArg.

Expand All @@ -512,6 +568,8 @@ DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInstantiat
DRProductionPrimitiveCompilationTest >> testCompilePrimitiveWithArgNewInstantiatesInteger64Array [

| class |
(cogit isKindOf: SimpleDruidTestRTLCompiler) ifTrue: [ ^ self skip ].

self timeLimit: (Duration minutes: 2).
self compileDruidPrimitive: #primitiveNewWithArg.

Expand Down
3 changes: 2 additions & 1 deletion Druid-Tests/DruidTestRTLCompiler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ DruidTestRTLCompiler class >> initializePrimitiveTable [

<generated>
MaxCompiledPrimitiveIndex := 0.
primitiveTable := CArrayAccessor on: (Array new: MaxCompiledPrimitiveIndex + 1).
primitiveTable := CArrayAccessor on:
(Array new: MaxCompiledPrimitiveIndex + 1).
self table: primitiveTable from: self primitiveTableArray.
^ primitiveTable
]
Expand Down
8 changes: 8 additions & 0 deletions Druid-Tests/DruidTestRTLCompilerForTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"
I am a compiler class that gets modified dynamically by some tests.
"
Class {
#name : #DruidTestRTLCompilerForTest,
#superclass : #DruidTestRTLCompiler,
#category : #'Druid-Tests'
}

0 comments on commit 6f8878a

Please sign in to comment.