X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
file library
asMethodReturningString: aByteArrayOrString named: aSymbol
"Generates the source of a method named aSymbol that returns aByteArrayOrString as a String.

This implementation answers a String formatted like so

aSymbol
^ aByteArrayOrString

Subclasses need to override this method if the dialect needs changes to support Unicode string literals"
^ String streamContents: [ :stream |
stream
nextPutAll: aSymbol;
nextPut: Character cr.
stream
tab;
nextPutAll: '^ '''.
aByteArrayOrString greaseString do: [ :each |
each = $' ifTrue: [ stream nextPut: $' ].
stream nextPut: each ].
stream nextPut: $' ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
file library
doSilently: aBlock
"Suspend all notifications value evaluating the given block."
^ aBlock value
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
running
runCase
GRPlatform current doSilently: [ super runCase ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
private
supportsUnicode
"dynamically try to figure out whether the current dialect supports Unicode"
^ [
String
with: (Character value: 16r1F1F3)
with: (Character value: 16r1F1F1).
true
] on: Error
do: [ :error | false ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
tests-file library
testCompileAsciiString
| selector expected source |

self supportsUnicode ifFalse: [
^ self ].

selector := #stringMethod.
expected := 'test ok'.
source := GRPlatform current asMethodReturningString: expected named: selector.
[
| actual |
GRPlatform current compile: source into: self class classified: 'private'.
actual := self perform: selector.
self assert: expected = actual
] ensure: [
GRPlatform current removeSelector: #stringMethod from: self class ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
tests-file library
testCompileUnicodeString
| selector expected source |
selector := #stringMethod.
expected := String
with: (Character value: 16r1F1F3)
with: (Character value: 16r1F1F1).
source := GRPlatform current asMethodReturningString: expected named: selector.
[
| actual |
GRPlatform current compile: source into: self class classified: 'private'.
actual := self perform: selector.
self assert: expected = actual
] ensure: [
GRPlatform current removeSelector: #stringMethod from: self class ]
X Tutup