'From Squeak6.0alpha of 12 May 2021 [latest update: #20523] on 14 May 2021 at 3:37:37 pm'!
Object variableSubclass: #InspectorTestObject
	instanceVariableNames: 'apple orange queries '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'ToolsTests-Inspector'!

!Inspector methodsFor: 'menu - commands' stamp: 'ct 5/14/2021 15:29'!
inspectOne

	^ self inspectOneOf: self elementIndices! !

!Inspector methodsFor: 'fields - truncation' stamp: 'ct 5/14/2021 14:48'!
contentsForTruncationOf: truncatedKeys

	^ ('<Fields named {1} to {2} are not shown. {3} to inspect one of those fields or select "inspect element" from the field list menu.>' translated asText
		addAttribute: TextEmphasis italic;
		format: {
			truncatedKeys first storeString.
			truncatedKeys last storeString. 
			'Click here' translated asText
				addAttribute: (PluggableTextAttribute evalBlock: [self inspectOneOf: truncatedKeys]);
				yourself. })! !

!Inspector methodsFor: 'menu - private' stamp: 'ct 5/14/2021 15:32'!
elementGetterAt: indexOrKey
	"Backstop to simplify #inspectOne for all kinds of inspectors."

	^ [:object | object basicAt: indexOrKey]! !

!Inspector methodsFor: 'fields - streaming' stamp: 'ct 5/14/2021 15:28'!
streamIndexedVariablesOn: aStream
	"Truncate indexed variables if there are too many of them."
	
	self
		streamOn: aStream
		truncate: self elementIndices
		collectFields: [:index |
			(self newFieldForType: #indexed key: index)
				valueGetter: [:object | object basicAt: index];
				valueSetter: [:object :value | object basicAt: index put: value];
				yourself]! !

!Inspector methodsFor: 'private' stamp: 'ct 5/14/2021 15:28'!
elementIndices

	^ 1 to: self object basicSize! !


!InspectorTest methodsFor: 'running' stamp: 'ct 5/14/2021 15:12'!
inspectObjectWithTruncatedIndexAndTestFieldDo: aBlock

	| object testObject truncatedIndex |
	object := self createObjectWithTruncation.
	self inspector object: object.
	truncatedIndex := object size - self inspector truncationTail.
	testObject := InspectorTestObject new.
	object at: truncatedIndex put: testObject.
	^ aBlock value: truncatedIndex value: testObject! !

!InspectorTest methodsFor: 'tests' stamp: 'ct 5/14/2021 15:18'!
testInspectOne

	(self class includesSelector: #createObjectWithTruncation)
		ifFalse: [^ self "Run this test only if explicitely refined."].
	
	self inspectObjectWithTruncatedIndexAndTestFieldDo: [:index :testObject |
		[self inspector inspectOne] valueSupplyingAnswer: {'*name of the field*'. index asString}.
		
		self assert: [testObject queries includes: #inspect]].! !


!InspectorTestObject methodsFor: 'as yet unclassified' stamp: 'ct 5/14/2021 14:56'!
queries

	^ queries! !

!InspectorTestObject methodsFor: 'initialize-release' stamp: 'ct 5/14/2021 14:56'!
initialize

	super initialize.
	
	queries := OrderedCollection new.! !

!InspectorTestObject methodsFor: 'inspecting' stamp: 'ct 5/14/2021 14:56'!
inspect

	queries add: #inspect.! !


!SetInspectorTest methodsFor: 'running' stamp: 'ct 5/14/2021 15:19'!
inspectObjectWithTruncatedIndexAndTestFieldDo: aBlock

	| object testObject truncatedIndex |
	object := self createObjectWithTruncation.
	self inspector object: object.
	truncatedIndex := object size - self inspector truncationTail.
	testObject := InspectorTestObject new.
	object array at: truncatedIndex put: testObject.
	^ aBlock value: truncatedIndex value: testObject! !

Object variableSubclass: #InspectorTestObject
	instanceVariableNames: 'apple orange queries'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'ToolsTests-Inspector'!

!InspectorTestObject reorganize!
('accessing' apple apple: fruits orange orange:)
('initialization' beInvalid)
('printing' printOn:)
('as yet unclassified' queries)
('initialize-release' initialize)
('inspecting' inspect)
!

CollectionInspector removeSelector: #inspectOne!
