-
Notifications
You must be signed in to change notification settings - Fork 22
Add #asMethodReturningString:named: #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
marschall
merged 2 commits into
SeasideSt:master
from
marschall:asMethodReturningString
Aug 25, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
repository/Grease-Core.package/GRPlatform.class/instance/asMethodReturningString.named..st
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: $' ] | ||
4 changes: 4 additions & 0 deletions
4
repository/Grease-Core.package/GRPlatform.class/instance/doSilently..st
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
3 changes: 3 additions & 0 deletions
3
repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/runCase.st
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| running | ||
| runCase | ||
| GRPlatform current doSilently: [ super runCase ] | ||
jbrichau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
10 changes: 10 additions & 0 deletions
10
repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/supportsUnicode.st
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 ] |
17 changes: 17 additions & 0 deletions
17
repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testCompileAsciiString.st
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 ] |
15 changes: 15 additions & 0 deletions
15
...itory/Grease-Tests-Core.package/GRPlatformTest.class/instance/testCompileUnicodeString.st
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 ] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.