mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Merge pull request #3288 from enquora/CPSetTest-fix-test-warning
Fix static analysis warnings for unused iteration variables in Founda…
This commit is contained in:
@@ -490,8 +490,11 @@
|
||||
var result = [CPMutableDictionary dictionary];
|
||||
|
||||
// Test basic for...of iteration
|
||||
for (var [key, value] of dict)
|
||||
for (var entry of dict)
|
||||
{
|
||||
var key = entry[0],
|
||||
value = entry[1];
|
||||
|
||||
[result setObject:value forKey:key];
|
||||
}
|
||||
|
||||
@@ -514,6 +517,8 @@
|
||||
var iterations = 0;
|
||||
for (var entry of emptyDict)
|
||||
{
|
||||
// Explicitly evaluate the bound variable to satisfy the static analyzer.
|
||||
[entry self];
|
||||
iterations++;
|
||||
}
|
||||
[self assert:0 equals:iterations message:@"for...of on an empty dictionary should not iterate"];
|
||||
|
||||
@@ -428,10 +428,19 @@
|
||||
|
||||
|
||||
// 3. Test on an empty set
|
||||
/*
|
||||
The bound variable must be explicitly read to satisfy the static analyzer.
|
||||
Standard JavaScript idioms for unused variables, such as the `_` identifier
|
||||
or the `void` operator, either fail linting or trigger AST collisions in the
|
||||
legacy Node.js parser. Evaluating the variable via a standard Objective-J
|
||||
message send resolves the warning while preserving parser stability.
|
||||
*/
|
||||
|
||||
var emptySet = [CPSet set];
|
||||
var iterations = 0;
|
||||
for (var entry of emptySet)
|
||||
{
|
||||
[itemsSeen addObject:entry];
|
||||
iterations++;
|
||||
}
|
||||
[self assert:0 equals:iterations message:@"for...of on an empty set should not iterate"];
|
||||
|
||||
Reference in New Issue
Block a user