Differences From Artifact [b3dcaccc4e]:
- File
tests/OFDictionaryTests.m
— part of check-in
[cbacea7ca3]
at
2016-06-05 14:32:21
on branch trunk
— Implement Key Value Coding for OFDictionary
If the key starts with an @, the @ is stripped and the super method is
called. Otherwise, this is equivalent to -[objectForKey:] /
-[setValue:forKey:]. (user: js, size: 7031) [annotate] [blame] [check-ins using]
To Artifact [c47931a3b5]:
- File
tests/OFDictionaryTests.m
— part of check-in
[f816d1ec7c]
at
2016-06-05 15:11:04
on branch trunk
— Move -[setValue:forKey:] to OFDictionary
If this is only overridden in OFMutableDictionary, this would lead to
inconsistent behavior, as it could be called on an OFDictionary as well
due to the fact that -[setValue:forKey:] is defined in OFObject.
Instead, if the dictionary is immutable, an OFUndefinedKeyException is
thrown. (user: js, size: 7224) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #import "OFDictionary.h" #import "OFString.h" #import "OFArray.h" #import "OFNumber.h" #import "OFAutoreleasePool.h" #import "OFEnumerationMutationException.h" #import "TestsAppDelegate.h" static OFString *module = @"OFDictionary"; static OFString *keys[] = { @"key1", @"key2" | > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #import "OFDictionary.h" #import "OFString.h" #import "OFArray.h" #import "OFNumber.h" #import "OFAutoreleasePool.h" #import "OFEnumerationMutationException.h" #import "OFUndefinedKeyException.h" #import "TestsAppDelegate.h" static OFString *module = @"OFDictionary"; static OFString *keys[] = { @"key1", @"key2" |
︙ | ︙ | |||
55 56 57 58 59 60 61 62 63 64 65 66 67 68 | [[dict objectForKey: keys[1]] isEqual: values[1]] && [dict objectForKey: @"key3"] == nil) TEST(@"-[valueForKey:]", [[dict valueForKey: keys[0]] isEqual: values[0]] && [[dict valueForKey: @"@count"] isEqual: [OFNumber numberWithSize: 2]]) TEST(@"-[containsObject:]", [dict containsObject: values[0]] && ![dict containsObject: @"nonexistant"]) TEST(@"-[containsObjectIdenticalTo:]", [dict containsObjectIdenticalTo: values[0]] && | > > > > | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | [[dict objectForKey: keys[1]] isEqual: values[1]] && [dict objectForKey: @"key3"] == nil) TEST(@"-[valueForKey:]", [[dict valueForKey: keys[0]] isEqual: values[0]] && [[dict valueForKey: @"@count"] isEqual: [OFNumber numberWithSize: 2]]) EXPECT_EXCEPTION(@"Catching -[setValue:forKey:] on immutable " @"dictionary", OFUndefinedKeyException, [dict setValue: @"x" forKey: @"x"]) TEST(@"-[containsObject:]", [dict containsObject: values[0]] && ![dict containsObject: @"nonexistant"]) TEST(@"-[containsObjectIdenticalTo:]", [dict containsObjectIdenticalTo: values[0]] && |
︙ | ︙ |