[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[scripting] 460 - Shortcuts

"Add test methods..."
! Object methodsFor: #test !
hello
	false ifFalse: [ ^#ok ] ifTrue: [ ^#bad ].
	^self error: #shouldNotHappen! !


"simple hello (false) with exit"
(ScriptParser new parse: ' 12 hello
' onError: [:error| ^self note: error description ]) evaluate = #ok ifFalse: [ self error: 'Must be #ok' ]


"Add test methods..."
! Object methodsFor: #test !
hello
	true ifTrue: [ ^#ok ] ifFalse: [ ^#bad ].
	^self error: #shouldNotHappen! !


"simple hello (true) with exit"
(ScriptParser new parse: ' 12 hello
' onError: [:error| ^self note: error description ]) evaluate = #ok ifFalse: [ self error: 'Must be #ok' ]


"Add test methods..."
! Object methodsFor: #test !
hello
	#(1 2 3) indexOf: #hello ifAbsent: [ ^#ok ].
	^self error: #shouldNotHappen! !


"simple hello (true) with exit"
(ScriptParser new parse: ' 12 hello
' onError: [:error| ^self note: error description ]) evaluate = #ok ifFalse: [ self error: 'Must be #ok' ]


"Remove test methods..."
Object removeSelector: #hello


"Pool #at:ifAbsent: with exit"
(ScriptParser new parse: '
    | pool | pool := PoolDictionary new.
    pool at: #hello put: #world.
    pool at: #missing ifAbsent: [ ^#ok ].
    self error: #ShouldNotHappen
' onError: [:error| ^self note: error description ]) evaluate = #ok ifFalse: [ self error: 'Must be #ok' ]


"Pool #at:ifAbsent: match "
(ScriptParser new parse: '
    | pool | pool := PoolDictionary new.
    pool at: #hello put: #ok.
    ^pool at: #hello ifAbsent: [ self error: #ShouldNotHappen ]
' onError: [:error| ^self note: error description ]) evaluate = #ok ifFalse: [ self error: 'Must be #ok' ]


"Array #at:ifAbsent: with exit"
(ScriptParser new parse: '
    | array | array := #(1 2 3).
    array at: 5 ifAbsent: [ ^#ok ].
    self error: #ShouldNotHappen
' onError: [:error| ^self note: error description ]) evaluate = #ok ifFalse: [ self error: 'Must be #ok' ]



"if with exit"
(ScriptParser new parse: '
	true ifTrue: [ ^true ] ifFalse: [ ^false ].
	self error: #ShouldNotHappen
' onError: [:error| ^self note: error description ]) evaluate mustBeBoolean ifFalse: [ self error: 'Must be boolean' ]


"if with exit"
(ScriptParser new parse: '
	false ifTrue: [ ^true ] ifFalse: [ ^false ].
	self error: #ShouldNotHappen
' onError: [:error| ^self note: error description ]) evaluate mustBeBoolean ifFalse: [ self error: 'Must be boolean' ]


"if with exit"
(ScriptParser new parse: '
	true ifFalse: [ ^true ] ifTrue: [ ^false ].
	self error: #ShouldNotHappen
' onError: [:error| ^self note: error description ]) evaluate mustBeBoolean ifFalse: [ self error: 'Must be boolean' ]


"if with exit"
(ScriptParser new parse: '
	false ifFalse: [ ^true ] ifTrue: [ ^false ].
	self error: #ShouldNotHappen
' onError: [:error| ^self note: error description ]) evaluate mustBeBoolean ifFalse: [ self error: 'Must be boolean' ]