Fixed allSelectorsSent because a simpler implementation was overriding the original.
[cslatevm.git] / tests / rot13.sh
blob7a10cd112a589d663eedae4ec2df301039c578e1
1 #!/usr/local/bin/slate
3 ch@(String Character traits) rot13
4 [| value upper |
5 upper: ch isUppercase.
6 value: (ch toLowercase as: Integer).
7 (value >= 97) /\ (value < 110)
8 ifTrue: [value: value + 13]
9 ifFalse: [(value > 109) /\ (value <= 122)
10 ifTrue: [value: value - 13]].
11 upper
12 ifTrue: [(value as: String Character) toUppercase]
13 ifFalse: [value as: String Character]
16 s@(String traits) rot13
17 [| result |
18 result: s newSameSize.
19 s doWithIndex: [| :each :index |
20 result at: index put: each rot13].
21 result
24 lobby define: #Rot13Encoder &parents: {Encoder}.
27 c@(Rot13Encoder traits) convert
29 [c in isAtEnd] whileFalse: [c out nextPut: c in next rot13].
33 (Rot13Encoder newFrom: Console reader to: Console writer) convert.