JavaScript now handles time a lot better. Times from before around 1900 is different in different
parts of the world so we just changed this test case to be a bit more modern.
An example:
var array = @[ @{@"Name": @"1"},
@{@"Name": @"2", @"approveTime": @"Now"}
];
var predicate = [CPPredicate predicateWithFormat:@"approveTime != nil"];
CPLog(@"result: %@", [array filteredArrayUsingPredicate:predicate]); // result: <empty array>
If I run this in Cappuccino I get an empty array
If I run it in Cocoa on a Mac I get:
result: (
{
Name = 2;
approveTime = Now;
}
Fixed: When dependent key paths use a relationship, only the first added observer will observe the attribute for the relationship object.
Also, an optimisation on when the willChange… chain is running, there is no need to replace the observers as no new values are set yet. That will be done when the didChange… chain is running.
We expect this method to return a whole number like in Objective-C. This also goes for the related methods, `shortValue`, `longValue` and `longLongValue`.
Also adds more tests (in addition to the existing, already failing test).
Previously a CPPredicate created with format `value == nil` was converted back to `value == <CPNull @ xxxx>`
This patch ensures `predicateFormat` returns `value == nil`
Test added in CPPredicateTest.j
Conditional Expression : an expression using different expressions for
evaluation, depending of a predicate result.
Support for predicate parsing: ```TERNARY(predicate, trueExpression,
falseExpression)```
With init, equal, evaluation, parsing tests.
When the predicate part of a subquery expression was containing
variables, the substitution was ignored.
Now, the subpredicate can contain variables that will be substituted
when calling evaluateWithObject:substitutionVariables:.
Added expression test and predicate parsing test.
Previously, we could only give a selector and a target for perform in the runLoop. Now we can give a block.
This feature is used in the CPTextField class. Previously, when we wanted to call a function at the end of the stack we used window.setTimeout, however due to HTML5 specifications this wasn't called just at the end of the stack but at least 4ms (more information here https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout#Minimum_delay_and_timeout_nesting). Now we give a block to perform, and this block will be performed in the next runloop.
Unittest has been added in Tests/Foundation/CPRunLoopTest.j
This PR adds the feature of CPNotificationQueue.
Cappuccino provides a framework for sending messages between objects within
a process called notifications. CPNotificationQueue objects (or simply notification queues)
act as buffers for notification centers (instances of CPNotificationCenter).
Whereas a notification center distributes notifications when posted,
notifications placed into the queue can be delayed until the end of the current pass through the run loop
or until the run loop is idle. Duplicate notifications can also be coalesced so that only one notification
is sent although multiple notifications are posted. A notification queue maintains notifications
(instances of C¨Notification) generally in a first in first out (FIFO) order.
When a notification rises to the front of the queue, the queue posts it to the notification center,
which in turn dispatches the notification to all objects registered as observers.
More informations here :https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNotificationQueue_Class/index.html#//apple_ref/occ/instm/NSNotificationQueue/enqueueNotification:postingStyle:coalesceMask:forModes:
Unit-Tests in Tests/Foundation/CPNotificationQueueTest.j
For example the method ’initWithName:’ will return different abbreviation depending on the order CPDictionary returns keys from the method ’keyEnumerator’. As this is undefined the answer can vary. Test cases now handle all cases.
When parsing a predicate format that contains a constant boolean expression
(e.g., 'key = YES') the value of the returned constant value expression has
the wrong type. Instead of using native types as values, the parser uses
[CPNumber +numberWithBool:].
This commit changes the format parser (CPPredicateScanner) to use native
booleans for constant value expression.
There's a test case that checks the parse result and an additional test
that ensures boolean expressions evaluate as expected with different kinds
of objects. The latter test passed before the fix but was added to ensure
compliance with Cocoa.
changes for fix#2332. The test-cased failed, because now a
a CPDecimalNumber has a different UID compared to a CPNumber with the same
value. That means isEqual: will return false. In the test-cases the formatter now
generates CPNumbers to make the two Numbers compareable via isEqual.