Files
purchases-ios/Tests/UnitTests/RulesEngine/StringArrayOperatorsTests.swift
T
Antonio PallaresandCursor f732e06eb6 refactor: namespace rules engine types under RulesEngine (#7295)
* refactor: move rules engine into core SDK as internal

Move the RulesEngineInternal sources and tests into the RevenueCat target
under Sources/RulesEngine and Tests/UnitTests/RulesEngine. The moved
symbols are marked internal so no new public API is exposed, and the
standalone RulesEngineInternal target is removed from Package manifests,
Tuist, the Xcode project, and CI. No usages yet.

Co-authored-by: Cursor <cursoragent@cursor.com>

* refactor: namespace rules engine types under RulesEngine

Nest the generically-named rules engine types (Value, Evaluator,
Operators and the per-category operator enums), the JS coercion helpers,
and PrintLogger inside the RulesEngine enum so the subsystem exposes a
single top-level symbol instead of polluting the RevenueCat module's
internal namespace. RulesEngineLogger stays top-level (already prefixed).
Production cross-references resolve via enclosing scope; tests use local
typealiases or explicit RulesEngine. qualification.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Document why the rules engine owns its own logging abstraction

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 18:26:46 +02:00

38 lines
1.0 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: .null
)
XCTAssertEqual(out, arr(arr(.int(1)), .int(2)))
}
// MARK: - Helpers
private func arr(_ items: Value...) -> Value {
.array(items)
}
}