mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-10 22:45:55 +05:45
* Add Scope plumbing and custom operator extension point Thread evaluation scope through the rules engine and delegate unknown operators to an empty CustomOperators dispatcher, without changing behavior. Co-authored-by: Cursor <cursoragent@cursor.com> * Fix project.pbxproj: restore RewardedAdTrackingMetadata entries The RulesEngine registration edit accidentally dropped four RewardedAdTrackingMetadata.swift entries from the Xcode project. Restore them and normalize CustomOperators identifiers to 24 hex chars. Co-authored-by: Cursor <cursoragent@cursor.com> * Promote firstArgEvaluated to shared Operators helpers Move the unary-arg helper from LogicOperators to Operators so custom operators can use the same json-logic-js spread convention. Co-authored-by: Cursor <cursoragent@cursor.com> * Address review comments on custom operator extension point Drop the cross-engine registration note from CustomOperators, and restore the single-line var extra-args warning that was reflowed without changing its text. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.1 KiB
Swift
38 lines
1.1 KiB
Swift
//
|
|
// StringArrayOperatorsTests.swift
|
|
//
|
|
// Created by Antonio Pallares.
|
|
//
|
|
|
|
import XCTest
|
|
|
|
@testable import RevenueCat
|
|
|
|
private typealias Value = RulesEngine.Value
|
|
private typealias StringArrayOperators = RulesEngine.StringArrayOperators
|
|
|
|
final class StringArrayOperatorsTests: XCTestCase {
|
|
|
|
// MARK: - merge
|
|
|
|
/// Kept as a Swift test (not migrated to a JSON fixture): `merge`
|
|
/// returns an array, and this engine's loose `==` string-coerces
|
|
/// `[[1], 2]` and `[1, 2]` to the same `"1,2"`, so no predicate can
|
|
/// verify that nested arrays are NOT recursively flattened. Only a
|
|
/// structural `Value` comparison can.
|
|
func testMergeDoesNotRecurseOnNestedArrays() throws {
|
|
// Only one level of flattening — inner arrays remain.
|
|
let out = try StringArrayOperators.opMerge(
|
|
args: arr(arr(arr(.int(1)), .int(2))),
|
|
vars: RulesEngine.Scope(root: Value.null)
|
|
)
|
|
XCTAssertEqual(out, arr(arr(.int(1)), .int(2)))
|
|
}
|
|
|
|
// MARK: - Helpers
|
|
|
|
private func arr(_ items: Value...) -> Value {
|
|
.array(items)
|
|
}
|
|
}
|