Browse files

fix another test failure

  • Loading branch information...
1 parent ccd6e1a commit 906e2a1f6edb682974910b1e3ef3a4c891d3828b @timfel timfel committed Jun 18, 2010
Showing with 19 additions and 16 deletions.
  1. +16 −14 JSON/JsonObject.st
  2. +3 −2 JSON/JsonTests.st
View
30 JSON/JsonObject.st
@@ -20,36 +20,37 @@ Object subclass: JsonObject [
^self at: aKey ifAbsent: [nil]
]
- dictionary: aDictionary [
+ dictionary [
<category: 'accessing'>
- aDictionary ifNotNil: [:foo | dictionary := aDictionary]
+ dictionary ifNil: [dictionary := Dictionary new].
+ ^dictionary
]
- dictionaryEquals: aDictionary [
+ dictionary: aDictionary [
<category: 'accessing'>
- ^dictionary = aDictionary
+ aDictionary ifNotNil: [:foo | dictionary := aDictionary]
]
= aJsonObject [
<category: 'overrides-to-dictionary'>
- ^aJsonObject dictionaryEquals: dictionary
+ ^aJsonObject dictionary = self dictionary
]
at: aKey put: aValue [
"override cause object defines this"
<category: 'overrides-to-dictionary'>
- ^dictionary at: aKey put: aValue
+ ^self dictionary at: aKey put: aValue
]
bindingOf: varName [
<category: 'overrides-to-dictionary'>
- ^dictionary bindingOf: varName
+ ^self dictionary bindingOf: varName
]
flattenOnStream: aStream [
<category: 'overrides-to-dictionary'>
- ^dictionary flattenOnStream: aStream
+ ^self dictionary flattenOnStream: aStream
]
isDictionary [
@@ -59,12 +60,12 @@ Object subclass: JsonObject [
javascriptOn: aStream [
<category: 'overrides-to-dictionary'>
- dictionary javascriptOn: aStream
+ self dictionary javascriptOn: aStream
]
jsonOn: aStream [
<category: 'overrides-to-dictionary'>
- dictionary jsonOn: aStream
+ self dictionary jsonOn: aStream
]
name [
@@ -76,7 +77,7 @@ Object subclass: JsonObject [
storeOn: aStream [
<category: 'overrides-to-dictionary'>
- ^dictionary storeOn: aStream
+ ^self dictionary storeOn: aStream
]
value [
@@ -89,15 +90,16 @@ Object subclass: JsonObject [
doesNotUnderstand: aMessage [
| key result |
- [result := aMessage sendTo: dictionary.
- ^result] on: MessageNotUnderstood
+ [result := aMessage sendTo: self dictionary.
+ ^result]
+ on: MessageNotUnderstood
do:
[key := aMessage selector.
key isUnary ifTrue: [^self at: key].
^(key isKeyword and: [(key occurrencesOf: $:) = 1])
ifTrue:
[key := key allButLast asSymbol.
- dictionary at: key put: aMessage arguments first]
+ self dictionary at: key put: aMessage arguments first]
ifFalse: [super doesNotUnderstand: aMessage]]
]
View
5 JSON/JsonTests.st
@@ -7,6 +7,7 @@ TestCase subclass: JsonTests [
| readValue |
readValue := self readFrom: aString.
self assert: readValue = aValue
+ description: readValue printString , ' = ' , aValue printString
]
readFrom: aString [
@@ -44,10 +45,10 @@ TestCase subclass: JsonTests [
testAtomNumber [
self json: '1' equals: 1.
self json: '0123' equals: 123.
- self json: '1.23e2' equals: 123.
self json: '-1' equals: -1.
self json: '-0' equals: 0.
- self json: '[-1.2]' equals: {1.2 negated}
+ self json: '[-1.2]' equals: {1.2 negated}.
+ self json: '1.23e2' equals: 123
]
testAtomString [

0 comments on commit 906e2a1

Please sign in to comment.