slsmalltalk/test2.st

77 lines
1.7 KiB
Smalltalk
Raw Permalink Normal View History

Object
subclass: #Test2
instanceVariableNames: ''!
{!
Test2 methods!
on: s
"try all classes"
| f t k |
(f <- File name: s mode: 'w') open.
t <- 9 asCharacter asString.
k <- classes sort: [ :x :y | x name asString < y name asString ].
k do: [ :e | self on: f tab: t put: e ].
f close!
on: s put: c
"try one class"
| f t |
(f <- File name: s mode: 'w') open.
t <- 9 asCharacter asString.
self on: f tab: t putCN: c.
self on: f tab: t putSN: c.
self on: f tab: t putVN: c.
self on: f tab: t putCM: c.
self on: f tab: t putIM: c.
f close!
on: f tab: t put: c
"try all classes"
self on: f tab: t putCN: c.
self on: f tab: t putSN: c.
self on: f tab: t putVN: c.
self on: f tab: t putCM: c.
self on: f tab: t putIM: c!
on: f tab: t putCM: c
| n v |
n <- 10 asCharacter.
f print: 'class methods'.
v <- c class methods sort: [ :x :y | x name asString < y name asString ].
f print: '==='.
v do: [ :e |
f print: e trimmedText.
f print: '===' ]!
on: f tab: t putCN: c
f print: 'class name' , t , c name asString!
on: f tab: t putIM: c
| n v |
n <- 10 asCharacter.
f print: 'methods'.
v <- c methods sort: [ :x :y | x name asString < y name asString ].
f print: '==='.
v do: [ :e |
f print: e trimmedText.
f print: '===' ]!
on: f tab: t putSN: c
| v |
v <- c superClass.
v isNil ifTrue: [
v <- '<nil>' ]
ifFalse: [
v <- v asString ].
f print: 'superclass name' , t , v!
on: f tab: t putVN: c
| v |
v <- c variables.
v isNil ifTrue: [
v <- #('<nil>') ]
ifFalse: [
v <- (v collect: [ :e | e asString ]) sort ].
v inject: 'variable names' into: [ :x :y |
f print: x , t , y.
' ' ]!
tryAll
"try all classes"
self on: 'test2.all.out'!
tryOne
"try one class"
self on: 'test2.one.out' put: self class!
}!