-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added testMultiple - added testStreaming - added testWhitespace - improved testError
- Loading branch information
Showing
5 changed files
with
36 additions
and
8 deletions.
There are no files selected for viewing
11 changes: 4 additions & 7 deletions
11
repository/Ston-Tests.package/STONReaderTests.class/instance/testError.st
This file contains 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 |
---|---|---|
@@ -1,9 +1,6 @@ | ||
tests | ||
testError | ||
self should: [ STON fromString: 'foo' ] raise: STONReaderError. | ||
self should: [ STON fromString: '{foo:}' ] raise: STONReaderError. | ||
self should: [ STON fromString: '{foo,}' ] raise: STONReaderError. | ||
self should: [ STON fromString: '[1,]' ] raise: STONReaderError. | ||
self should: [ STON fromString: '+1' ] raise: STONReaderError. | ||
self should: [ STON fromString: ']' ] raise: STONReaderError. | ||
self should: [ STON fromString: '#' ] raise: STONReaderError | ||
#( 'foo' '{foo:}' '{foo,}' '[1,]' '+1' ']' '#' '' ' ' ' ' 'nul' 'tru' 'fals' ) do: [ :each | | ||
self | ||
should: [ self materialize: each ] | ||
raise: STONReaderError ] |
15 changes: 15 additions & 0 deletions
15
repository/Ston-Tests.package/STONReaderTests.class/instance/testMultiple.st
This file contains 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 | ||
testMultiple | ||
| reader | | ||
reader := STON reader | ||
on: '123 -123 nil #foo true [ 0 ] false { #one : 1 }' readStream. | ||
self deny: reader atEnd. | ||
self assert: reader next equals: 123. | ||
self assert: reader next equals: -123. | ||
self assert: reader next equals: nil. | ||
self assert: reader next equals: #foo. | ||
self assert: reader next equals: true. | ||
self assert: reader next equals: { 0 }. | ||
self assert: reader next equals: false. | ||
self assert: reader next equals: (Dictionary with: #one -> 1). | ||
self assert: reader atEnd. |
10 changes: 10 additions & 0 deletions
10
repository/Ston-Tests.package/STONReaderTests.class/instance/testStreaming.st
This file contains 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 @@ | ||
tests | ||
testStreaming | ||
| reader | | ||
reader := STON reader | ||
on: '1 2 3 4 5 6 7 8 9 10' readStream. | ||
self | ||
assert: (Array streamContents: [ :stream | | ||
[ reader atEnd] whileFalse: [ | ||
stream nextPut: reader next ] ]) sum | ||
equals: #(1 2 3 4 5 6 7 8 9 10) sum |
6 changes: 6 additions & 0 deletions
6
repository/Ston-Tests.package/STONReaderTests.class/instance/testWhitespace.st
This file contains 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,6 @@ | ||
tests | ||
testWhitespace | ||
| whitespace | | ||
whitespace := { Character space. Character tab. Character cr. Character lf }. | ||
self assert: (self materialize: whitespace, '123') = 123 | ||
|
This file contains 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