[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
test[scripting] 400 - S8 Syntax extensions
Read more on S8 Syntax extensions.
"inlined code"
((ScriptParser new
parse: ${ ,#smalltalk printString ,$}
onError: [:error| ^self note: 'NIY - ',error description ]) evaluate: 5) == Smalltalk current ifFalse: [ self error: 'Must be smalltalk' ]
"accessing native property (lowercase)"
(ScriptParser new parse: '
| st | st := Smalltalk current.
st#useManager isKindOf: Boolean
' onError: [:error| ^self note: 'NIY - ',error description ]) evaluate == true ifFalse: [ self error: 'Must be a Boolean' ]
"accessing native property (uppercase)"
(ScriptParser new parse: '
| st | st := Smalltalk current.
st#Object
' onError: [:error| ^self note: 'NIY - ',error description ]) evaluate == Object ifFalse: [ self error: 'Must be Object' ]
"accessing native property (alien)"
(ScriptParser new parse: '
| st | st := Smalltalk current. st#$nativeLanguage
' onError: [:error| ^self note: 'NIY - ',error description ]) evaluate isString ifFalse: [ self error: 'Must be aString' ]
"native lookup"
(ScriptParser new parse: '
#{smalltalk}
' onError: [:error| ^self note: 'NIY - ',error description ]) evaluate == Smalltalk current ifFalse: [ self error: 'Must be #{smalltalk}' ]
"no receiver"
(ScriptParser new parse: '
# print
' onError: [:error| ^self note: 'NIY - ',error description ]) evaluate
"native call"
(ScriptParser new parse: '
self #yourself == self
' onError: [:error| ^self note: 'NIY - ',error description ]) evaluate = true ifFalse: [ self error: 'Must return true' ]
"native call (more arguments)"
(ScriptParser new parse: '
# #print: #hello with: $ with: #world
' onError: [:error| ^self note: 'NIY - ',error description ]) evaluate
"native indexing"
(ScriptParser new parse: '| i a |
i := 0. a := #(1 2 3).
a[0] = 1 ifFalse: [ self error: ''Wrong indexing result'' ].
a[i + 1] := 3. a[#123 size] := 6.
a = #(1 3 3 6) ifFalse: [ self error: ''Wrong result. Must be '' ,#(1 3 3 6) asLiteral ]
' onError: [:error| ^self note: 'NIY - ',error description ]) evaluate.!