<commit_before>Class {
	#name : #RSExamplesTest,
	#superclass : #RSTest,
	#category : #'Roassal3-Global-Tests-Examples'
}

{ #category : #tests }
RSExamplesTest >> executeTest: method in: exampleClass [
	| res |
	res := exampleClass perform: method selector.
	self
		deny: res = exampleClass
		description: '''' , method selector, ''', should return a canvas or view.'
		
]

{ #category : #tests }
RSExamplesTest >> testExamples [
	"This tests execute all the examples of Roassal. Introspectively, it looks for subclasses of RSAbstractExamples"
	| clazz withErrors sameResult |
	self timeLimit: 10 minutes.
	clazz := Smalltalk at: #RSAbstractExamples ifAbsent: [ ^ self ].
	withErrors := OrderedCollection new.
	sameResult := OrderedCollection new.
	clazz subclasses do: [ :cls | 
		| inst methods |
		inst := cls new.
		methods := cls methods 
			select: [ :met | 
				(met selector beginsWith: 'example') 
				and: [ (met hasPragmaNamed: 'noTest') not ] ].
		methods sort: CompiledMethod sortBlock.
		methods
			do: [ :met | | res |
				[res := inst perform: met selector.
				res = inst ifTrue: [ sameResult add: met ]]
				on: Error do: [ :ex | withErrors add: met ]
				 ]
			displayingProgress: [ :met | met selector ]
			every: 100 ]
		displayingProgress: [ :cls | cls asString ]
		every: 500.
		
	self assert: withErrors isEmpty description: 'All examples in roassal should run'.
	self assert: sameResult isEmpty description: 'All examples should return a canvas or builder'


]<commit_msg>update testing code <commit_after>Class {
	#name : #RSExamplesTest,
	#superclass : #RSTest,
	#category : #'Roassal3-Global-Tests-Examples'
}

{ #category : #tests }
RSExamplesTest >> executeTest: method in: exampleClass [
	| res |
	res := exampleClass perform: method selector.
	self
		deny: res = exampleClass
		description: '''' , method selector, ''', should return a canvas or view.'
		
]

{ #category : #tests }
RSExamplesTest >> testExamples [
	"This tests execute all the examples of Roassal. Introspectively, it looks for subclasses of RSAbstractExamples"
	| clazz withErrors sameResult |
	self timeLimit: 10 minutes.
	clazz := Smalltalk at: #RSAbstractExamples ifAbsent: [ ^ self ].
	withErrors := OrderedCollection new.
	sameResult := OrderedCollection new.
	clazz subclasses do: [ :cls | 
		| inst methods |
		inst := cls new.
		methods := cls methods 
			select: [ :met | 
				(met selector beginsWith: 'example') 
				and: [ (met hasPragmaNamed: 'noTest') not ] ].
		methods sort: CompiledMethod sortBlock.
		methods
			do: [ :met | | res |
				[res := inst perform: met selector.
				res = inst ifTrue: [ sameResult add: met ]]
				on: Error do: [ :ex | withErrors add: met ]
				 ]
			displayingProgress: [ :met | met selector ]
			every: 100 ]
		displayingProgress: [ :cls | cls asString ]
		every: 500.
	withErrors ifNotEmpty: [ 
		'Examples with errors: ' traceCr.
		withErrors traceCr. ].
	
	self assert: withErrors isEmpty description: 'All examples in roassal should run'.
	self assert: sameResult isEmpty description: 'All examples should return a canvas or builder'


]
{'fraction_non_alphanumeric': 0.10970873786407767, 'fraction_numerical': 0.005825242718446602, 'mean_word_length': 3.704718417047184, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2552884', 'n_tokens_mistral': 1074, 'n_tokens_neox': 959, 'n_words': 323}