diff --git a/Tests/Foundation/CPDictionaryTest.j b/Tests/Foundation/CPDictionaryTest.j index a94e05a38..299ee7685 100644 --- a/Tests/Foundation/CPDictionaryTest.j +++ b/Tests/Foundation/CPDictionaryTest.j @@ -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"]; diff --git a/Tests/Foundation/CPSetTest.j b/Tests/Foundation/CPSetTest.j index 414517361..7bd5ea760 100644 --- a/Tests/Foundation/CPSetTest.j +++ b/Tests/Foundation/CPSetTest.j @@ -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"];