[squeak-dev] KernelTests-ct.409

christoph.thiede at student.hpi.uni-potsdam.de christoph.thiede at student.hpi.uni-potsdam.de
Wed Nov 10 00:48:35 UTC 2021


Note that these tests cause multiple failures in a recent VM at the time of writing:

- #testPrimitive100/{'not a selector'. {}. Object}: The VM sends #doesNotUnderstand: to the receiver with an invalid selector whereas the simulator has the primitive failed as expected in Object>>perform:withArguments:inSuperclass:. What behavior do we want? (I would opt for the latter one.)
- #testPrimitive118/{6. 'not a primitive'. {7}},{6. 9. 'not an array'}: The VM returns an error code of -3 whereas the simulator returns no error code (nil). I have adjust this behavior in the simulator via Kernel-ct.1420.
- #testPrimitive118/{6. 118. {9. {7. 13}}}: The VM does not check the number of arguments but ignores the first one whereas the simulator has the primitive failed with #'bad number of arguments'. What behavior do we want? (I would opt for the latter one.)
- #testPrimitive118/2: Context>>receiver:tryPrimitive:withArgs: seems pretty buggy; not all arguments are popped from the stack and there occur several serious stack invalidations.

In my opinion most of these issues need to be addressed in the VM; if a new release wasn't just around the corner, it would be my pleasure to use these failures as some good starter entrypoints into the VMMaker project during Christmas or so. But if we are in a hurry, probably someone else wants to fix these issues earlier. Or we just mark the relevant tests as expected failures for now.

PS: Please don't ask me why the diff was not sent to the list this time. There should not be any special characters!


==================== Summary ====================

Name: KernelTests-ct.409
Author: ct
Time: 10 November 2021, 1:45:40.105242 am
UUID: ab3db7b1-d980-5b4b-80a2-8c08bef9b23b
Ancestors: KernelTests-mt.407

Adds new simulation tests for the reflection primitives 117 (primitiveExternalCall), 118 (primitiveDoPrimitiveWithArgs), and 218 (primitiveDoNamedPrimitiveWithArgs) and revises existing tests for the primitives 83 (primitivePerform), 84 (primitivePerformWithArgs), and 100 (primitivePerformInSuperclass) which do not need to be dispatched via primitive 118.

=============== Diff against KernelTests-mt.407 ===============

ContextTest>>testPrimitive100 {tests} · ct 11/10/2021 00:38 (changed)
testPrimitive100

	{
		{#isNil. {}. Object}. "valid 0-arg message"
		{#=. {true}. UndefinedObject}. "valid unary message"
		{#ifNil:ifNotNil:. {[2]. [:x | x]}. Object}. "valid binary message"
		{{}. #=. {true}. SequenceableCollection}. "mirror primitive"
- 		{#isNil}. "missing arguments"
- 		{#isNil. 'not an array'}. "invalid arguments"
- 		{#isNil. {}}. "missing lookupClass"
+ 		{'not a selector'. {}. Object}. "invalid selector"
+ 		{#isNil. 'not an array'. Object}. "invalid arguments"
		{#isNil. {'excess arg'}. Object}. "too many arguments"
		{#=. {}. UndefinedObject}. "missing argument"
+ 		{#isNil. {}. 'not a class'}. "invalid lookupClass"
		{#isNil. {}. Boolean}. "lookupClass not in inheritance chain"
- 	} do: [:args |
+ 	} do: [:args | | block |
+ 		block := [[nil
+ 			perform: args first
+ 			withArguments: args second
+ 			inSuperclass: args third]
+ 				on: Error do: [:ex | ex messageText]].
		self
- 			assert: (nil tryPrimitive: 100 withArgs: args)
- 			equals: (Context runSimulated: [nil tryPrimitive: 100 withArgs: args])].
+ 			assert: block value
+ 			equals: (Context runSimulated: block).
+ 		
+ 		block := [[thisContext
+ 			object: nil
+ 			perform: args first
+ 			withArguments: args second
+ 			inClass: args third]
+ 				on: Error do: [:ex | ex messageText]].
+ 		self
+ 			assert: block value
+ 			equals: (Context runSimulated: block)].

ContextTest>>testPrimitive117 {tests} · ct 11/10/2021 00:10
+ testPrimitive117
+ 
+ 	| input1 input2 |
+ 	"valid 0-arg primitive"
+ 	self
+ 		assert: #isNil size
+ 		equals: (Context runSimulated: [#isNil size]).
+ 	
+ 	"valid unary primitive"
+ 	self
+ 		assert: 6 + 9
+ 		equals: (Context runSimulated: [6 + 9]).
+ 	
+ 	"superfluous arguments"
+ 	self "cascade!"
+ 		assert: 6 + 9
+ 			equals: (Context runSimulated: [6 + 9]);
+ 		assert: true.
+ 	
+ 	self
+ 		assert: ((input1 := {1. 2. 3}) at: 2 put: 4)
+ 			equals: (Context runSimulated: [(input2 := {1. 2. 3}) at: 2 put: 4]);
+ 		assert: input1
+ 			equals: input2.

ContextTest>>testPrimitive118 {tests} · ct 11/10/2021 00:56
+ testPrimitive118
+ 
+ 	self testPrimitive118: [:receiver :primitiveIndex :arguments |
+ 		receiver tryPrimitive: primitiveIndex withArgs: arguments].
+ 	
+ 	self testPrimitive118: [:receiver :primitiveIndex :arguments |
+ 		thisContext receiver: receiver tryPrimitive: primitiveIndex withArgs: arguments].

ContextTest>>testPrimitive118: {tests} · ct 11/10/2021 01:23
+ testPrimitive118: primitiveBlock
+ 
+ 	| input1 input2 |
+ 	{
+ 		{#isNil. 62. {}}. "valid 0-arg primitive"
+ 		{6. 9. {7}}. "valid unary primitive"
+ 		{6. 62. {7}}. "failing primitive"
+ 		{6. 'not a primitive'. {7}}. "invalid primitive"
+ 		{6. 9. 'not an array'}. "invalid arguments"
+ 		{#isNil. 62. {1}}. "too many arguments"
+ 		{6. 9. {}}. "missing argument"
+ 		
+ 		{nil. 83. {#=. true}}. "primitivePerform"
+ 		{nil. 83. {#isNil. 'excess arg'}}. "primitivePerform - too many arguments"
+ 		{nil. 84. {#=. {true}}}. "primitivePerformWithArgs"
+ 		{nil. 84. {#isNil. 'excess arg'}}. "primitivePerformWithArgs - invalid arguments"
+ 		{nil. 100. {#=. true. Object}}. "primitivePerformInSuperclass"
+ 		{nil. 100. {#isNil. {'excess arg'}. Object}}. "primitivePerformInSuperclass - too many arguments"
+ 		
+ 		{6. 118. {9. {7}}}. "primitiveDoPrimitiveWithArgs"
+ 		{6. 118. {9. {7. 13}}}. "primitiveDoPrimitiveWithArgs - superfluous arguments"
+ 		{6. 118. {118. {9. {7}}}}. "primitiveDoPrimitiveWithArgs - M3"
+ 		{thisContext. 218. {Float32Array >> #sum. Float32Array withAll: {2.0. 3.0}. {}}}. "primitiveDoNamedPrimitiveWithArgs"
+ 		{thisContext. 218. {Float32Array >> #sum. Float32Array withAll: {2.0. 3.0}. {4.0}}}. "primitiveDoNamedPrimitiveWithArgs - superfluous arguments"
+ 	} do: [:args | | block |
+ 		block := [primitiveBlock valueWithArguments: args].
+ 		self
+ 			assert: block value
+ 			equals: (Context runSimulated: block)].
+ 	
+ 	self
+ 		assert: (primitiveBlock value: (input1 := {1. 2. 3}) value: 61 value: {2. 4})
+ 			equals: (Context runSimulated: [primitiveBlock value: (input2 := {1. 2. 3}) value: 61 value: {2. 4}]);
+ 		assert: input1
+ 			equals: input2.

ContextTest>>testPrimitive218 {tests} · ct 11/10/2021 00:13
+ testPrimitive218
+ 
+ 	"valid 0-arg primitive"
+ 	self
+ 		assert: (Float32Array withAll: {2.0. 3.0}) sum
+ 		equals: (Context runSimulated: [(Float32Array withAll: {2.0. 3.0}) sum]).
+ 	
+ 	"valid unary primitive"
+ 	self
+ 		assert: 'wiffy' = 'wiffy' copy
+ 			equals: (Context runSimulated: ['wiffy' = 'wiffy' copy]);
+ 		assert: 'wiffy' = 'ziffy'
+ 			equals: (Context runSimulated: ['wiffy' = 'ziffy']).
+ 	
+ 	"superfluous arguments"
+ 	self "cascade!"
+ 		assert: 'wiffy' = 'wiffy' copy
+ 			equals: (Context runSimulated: ['wiffy' = 'wiffy' copy]);
+ 		assert: true.

ContextTest>>testPrimitive83 {tests} · ct 11/10/2021 00:24 (changed)
testPrimitive83

	{
- 		{#isNil}. "valid 0-arg message"
- 		{#=. true}. "valid unary message"
- 		{#ifNil:ifNotNil:. [2]. [:x | x]}. "valid binary message"
- 		{#isNil. 'excess arg'}. "too many arguments"
- 		{#=}. "missing argument"
- 	} do: [:args |
+ 		[nil perform: #isNil]. "valid 0-arg message"
+ 		[nil perform: #= with: true]. "valid unary message"
+ 		[nil perform: #ifNil:ifNotNil: with: [2] with: [:x | x]]. "valid binary message"
+ 		[nil perform: #isNil with: 'excess arg']. "too many arguments"
+ 		[nil perform: #=]
+ 	} do: [:block |
		self
- 			assert: (nil tryPrimitive: 83 withArgs: args)
- 			equals: (Context runSimulated: [nil tryPrimitive: 83 withArgs: args])].
+ 			assert: (block on: Error do: [:ex | ex messageText])
+ 			equals: (Context runSimulated: [block on: Error do: [:ex | ex messageText]])].

ContextTest>>testPrimitive84 {tests} · ct 11/10/2021 00:21 (changed)
testPrimitive84

	{
		{#isNil. {}}. "valid 0-arg message"
		{#=. {true}}. "valid unary message"
		{#ifNil:ifNotNil:. {[2]. [:x | x]}}. "valid binary message"
- 		{#isNil}. "missing arguments"
		{#isNil. 'not an array'}. "invalid arguments"
		{#isNil. {'excess arg'}}. "too many arguments"
		{#=. {}}. "missing argument"
	} do: [:args |
		self
- 			assert: (nil tryPrimitive: 84 withArgs: args)
- 			equals: (Context runSimulated: [nil tryPrimitive: 84 withArgs: args])].
+ 			assert: ([nil perform: args first withArguments: args second] on: Error do: [:ex | ex messageText])
+ 			equals: (Context runSimulated: [[nil perform: args first withArguments: args second] on: Error do: [:ex | ex messageText]])].

---
Sent from Squeak Inbox Talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211110/5470f9a1/attachment.html>


More information about the Squeak-dev mailing list