From 8b04d2b833e32a33731e3d47109e49a152540dd6 Mon Sep 17 00:00:00 2001 From: Aleksei Menshutin Date: Fri, 4 Dec 2026 03:33:03 +0100 Subject: [PATCH] Evaluate a higher capacity for tracked TypeScript Array.map --- .../call/intrinsic/TsArrayEtsIrModelFamily.kt | 141 ++++++++++-------- .../call/intrinsic/TsArraySlotPrimitives.kt | 38 ++++- .../usvm/machine/call/models/ArrayModels.ts | 6 +- .../org/usvm/machine/call/MapCapacityTest.kt | 118 +++++++++++++++ .../call/TsUnknownCallModelCatalogTest.kt | 17 +++ .../models/map-capacity/MapCapacityCases.ts | 67 +++++++++ 6 files changed, 321 insertions(+), 66 deletions(-) create mode 100644 usvm-ts/src/test/kotlin/org/usvm/machine/call/MapCapacityTest.kt create mode 100644 usvm-ts/src/test/resources/models/map-capacity/MapCapacityCases.ts diff --git a/usvm-ts/src/main/kotlin/org/usvm/machine/call/intrinsic/TsArrayEtsIrModelFamily.kt b/usvm-ts/src/main/kotlin/org/usvm/machine/call/intrinsic/TsArrayEtsIrModelFamily.kt index e349d46462..606088822c 100644 --- a/usvm-ts/src/main/kotlin/org/usvm/machine/call/intrinsic/TsArrayEtsIrModelFamily.kt +++ b/usvm-ts/src/main/kotlin/org/usvm/machine/call/intrinsic/TsArrayEtsIrModelFamily.kt @@ -1,5 +1,6 @@ package org.usvm.machine.call.intrinsic +import io.ksmt.expr.KFp64Value import io.ksmt.utils.asExpr import io.ksmt.utils.cast import org.jacodb.ets.model.EtsAnyType @@ -38,12 +39,13 @@ import org.usvm.util.initializeArrayKind import org.usvm.util.isUnmodifiedDenseInputArray import org.usvm.util.mkArrayLengthLValue +private const val MAX_SOURCE_ARRAY_LENGTH = 16 + /** Built-in Array algorithms implemented by ordinary TypeScript bodies. */ internal object TsArrayEtsIrModelFamily : TsBuiltInUnknownCallModelFamily { private const val CLASS_NAME = "ArrayModels" private const val PRIMITIVES_CLASS_NAME = "ArrayModelPrimitives" private const val RESOURCE_NAME = "/org/usvm/machine/call/models/ArrayModels.ts" - private const val MAX_SOURCE_ARRAY_LENGTH = 16 private const val MAX_VARIADIC_ARGUMENTS = 3 private const val MAX_FILL_ARGUMENTS = 3 @@ -329,7 +331,7 @@ internal object TsArrayEtsIrModelFamily : TsBuiltInUnknownCallModelFamily { id = "ts.array.map", methodName = "map", inputAdapter = TsDenseArrayModelSupport.callbackAdapter, - domainGuard = TsArraySlotPrimitives.reverseDomain, + domainGuard = TsArraySlotPrimitives.mapDomain, ), sourceModel( id = "ts.array.forEach", @@ -408,6 +410,18 @@ internal object TsArrayEtsIrModelFamily : TsBuiltInUnknownCallModelFamily { arity = 1, implementation = TsArraySlotPrimitives::prepareOwnSlots, ), + primitiveModel( + methodName = "prepareMapOwnSlots", + arity = 1, + implementation = TsArraySlotPrimitives::prepareMapOwnSlots, + unsupportedCallPolicy = TsResidualCallPolicy.STOP_PATH, + ), + primitiveModel( + methodName = "allocateMapOutput", + arity = 1, + implementation = { state, inputs -> allocateArray(state, inputs, allowLargerMap = true) }, + unsupportedCallPolicy = TsResidualCallPolicy.STOP_PATH, + ), primitiveModel( methodName = "hasOwnSlot", arity = 2, @@ -421,7 +435,7 @@ internal object TsArrayEtsIrModelFamily : TsBuiltInUnknownCallModelFamily { primitiveModel( methodName = "allocate", arity = 1, - implementation = ::allocateArray, + implementation = { state, inputs -> allocateArray(state, inputs) }, ), primitiveModel( methodName = "allocateLike", @@ -451,7 +465,8 @@ internal object TsArrayEtsIrModelFamily : TsBuiltInUnknownCallModelFamily { inputAdapter = inputAdapter, requiredModelIds = buildSet { if (methodName in setOf("reverse", "unshift", "map", "forEach")) { - add("ts.array.primitive.prepareOwnSlots") + val prepareSlots = if (methodName == "map") "prepareMapOwnSlots" else "prepareOwnSlots" + add("ts.array.primitive." + prepareSlots) add("ts.array.primitive.hasOwnSlot") } if (methodName == "join") { @@ -470,7 +485,7 @@ internal object TsArrayEtsIrModelFamily : TsBuiltInUnknownCallModelFamily { add(PRIMITIVE_GROW_ID) } if (methodName == "map") { - add(PRIMITIVE_ALLOCATE_ID) + add("ts.array.primitive.allocateMapOutput") } if (methodName in setOf("slice", "concat")) { add(PRIMITIVE_ALLOCATE_LIKE_ID) @@ -555,62 +570,6 @@ internal object TsArrayEtsIrModelFamily : TsBuiltInUnknownCallModelFamily { ) } - private fun allocateArray( - state: TsState, - inputs: List>, - ): TsUnknownCallModelExecution? = with(state.ctx) { - val fpLength = inputs.singleOrNull() - ?.takeIf { value -> value.sort == fp64Sort } - ?.asExpr(fp64Sort) - ?: return null - val validLength = mkValidArrayLength(fpLength) - val maximumLength = mkFp64(MAX_SOURCE_ARRAY_LENGTH.toDouble()) - val withinModelCapacity = mkFpLessOrEqualExpr( - fpLength, - maximumLength, - ) - val supportedLength = mkAnd(validLength, withinModelCapacity) - val length = mkFpToUint32AfterValidation(fpLength, validLength).asExpr(sizeSort) - val arrayType = EtsArrayType(EtsUnknownType, dimensions = 1) - - // The model covers only valid, bounded one-number lengths. All other inputs remain residual. - val validSuccessor = TsUnknownCallModelSuccessor( - guard = supportedLength, - completion = TsUnknownCallModelCompletion.Normal { - val descriptor = arrayDescriptorOf(arrayType) - val result = memory.allocConcrete(arrayType) - val undefinedSlots = List(MAX_SOURCE_ARRAY_LENGTH) { mkUndefinedValue() } - memory.initializeArray( - arrayHeapRef = result, - type = descriptor, - sort = addressSort, - sizeSort = sizeSort, - contents = undefinedSlots.asSequence(), - ) - TsUnresolvedArrayKind.entries.forEach { kind -> - initializeArrayKind( - array = result, - kind = kind, - values = List(MAX_SOURCE_ARRAY_LENGTH) { falseExpr }, - ) - } - memory.initializeArrayLength( - arrayHeapRef = result, - type = descriptor, - sizeSort = sizeSort, - count = length, - ) - // Fresh allocations have known holes until the source algorithm writes each own slot. - knownArrayPropertyPresence += result - result - }, - ) - TsUnknownCallModelExecution( - successors = listOf(validSuccessor), - residualGuard = mkNot(supportedLength), - ) - } - private fun allocateArrayLike( state: TsState, inputs: List>, @@ -684,3 +643,63 @@ internal object TsArrayEtsIrModelFamily : TsBuiltInUnknownCallModelFamily { private const val PRIMITIVE_ALLOCATE_LIKE_ID = "ts.array.primitive.allocateLike" private const val UNKNOWN_SIGNATURE_COMPONENT = "%unk" } + +private fun allocateArray( + state: TsState, + inputs: List>, + allowLargerMap: Boolean = false, +): TsUnknownCallModelExecution? = with(state.ctx) { + val fpLength = inputs.singleOrNull() + ?.takeIf { value -> value.sort == fp64Sort } + ?.asExpr(fp64Sort) + ?: return null + val concreteLength = (fpLength as? KFp64Value)?.value + val largerMap = allowLargerMap && concreteLength != null && concreteLength > MAX_SOURCE_ARRAY_LENGTH + val maximumSize = if (largerMap) MAX_CONCRETE_MAP_LENGTH else MAX_SOURCE_ARRAY_LENGTH + val validLength = mkValidArrayLength(fpLength) + val maximumLength = mkFp64(maximumSize.toDouble()) + val withinModelCapacity = mkFpLessOrEqualExpr( + fpLength, + maximumLength, + ) + val supportedLength = mkAnd(validLength, withinModelCapacity) + val length = mkFpToUint32AfterValidation(fpLength, validLength).asExpr(sizeSort) + val arrayType = EtsArrayType(EtsUnknownType, dimensions = 1) + + // The model covers only valid, bounded one-number lengths. All other inputs remain residual. + val validSuccessor = TsUnknownCallModelSuccessor( + guard = supportedLength, + completion = TsUnknownCallModelCompletion.Normal { + val descriptor = arrayDescriptorOf(arrayType) + val result = memory.allocConcrete(arrayType) + val undefinedSlots = List(maximumSize) { mkUndefinedValue() } + memory.initializeArray( + arrayHeapRef = result, + type = descriptor, + sort = addressSort, + sizeSort = sizeSort, + contents = undefinedSlots.asSequence(), + ) + TsUnresolvedArrayKind.entries.forEach { kind -> + initializeArrayKind( + array = result, + kind = kind, + values = List(maximumSize) { falseExpr }, + ) + } + memory.initializeArrayLength( + arrayHeapRef = result, + type = descriptor, + sizeSort = sizeSort, + count = length, + ) + // Fresh allocations have known holes until the source algorithm writes each own slot. + knownArrayPropertyPresence += result + result + }, + ) + TsUnknownCallModelExecution( + successors = listOf(validSuccessor), + residualGuard = mkNot(supportedLength), + ) +} diff --git a/usvm-ts/src/main/kotlin/org/usvm/machine/call/intrinsic/TsArraySlotPrimitives.kt b/usvm-ts/src/main/kotlin/org/usvm/machine/call/intrinsic/TsArraySlotPrimitives.kt index f3568052cc..77b7507ee6 100644 --- a/usvm-ts/src/main/kotlin/org/usvm/machine/call/intrinsic/TsArraySlotPrimitives.kt +++ b/usvm-ts/src/main/kotlin/org/usvm/machine/call/intrinsic/TsArraySlotPrimitives.kt @@ -1,5 +1,6 @@ package org.usvm.machine.call.intrinsic +import io.ksmt.expr.KBitVec32Value import io.ksmt.utils.asExpr import org.jacodb.ets.model.EtsArrayType import org.jacodb.ets.model.EtsUnknownType @@ -21,12 +22,18 @@ import org.usvm.util.knownArrayIndexPresence import org.usvm.util.markDenseArrayOwnSlots import org.usvm.util.mkArrayLengthLValue +internal const val MAX_CONCRETE_MAP_LENGTH = 64 + /** Own-slot metadata operations used by the source reverse and unshift algorithms. */ internal object TsArraySlotPrimitives { val reverseDomain = TsEtsIrUnknownCallModelDomainGuard { state, call, inputs -> knownSlotGuard(state, call, inputs, additionalSlots = 0) } + val mapDomain = TsEtsIrUnknownCallModelDomainGuard { state, call, inputs -> + knownSlotGuard(state, call, inputs, additionalSlots = 0, allowLargerMap = true) + } + val unshiftDomain = TsEtsIrUnknownCallModelDomainGuard { state, call, inputs -> knownSlotGuard(state, call, inputs, additionalSlots = call.arguments.size) } @@ -36,15 +43,27 @@ internal object TsArraySlotPrimitives { call: TsUnknownCall, inputs: List>, additionalSlots: Int, + allowLargerMap: Boolean = false, ): UBoolExpr { val (array, type) = state.concreteArray(call, inputs) ?: return state.ctx.falseExpr val hasSlotProof = array in state.knownArrayPropertyPresence || state.hasDenseArrayShape(array, type) if (!hasSlotProof) return state.ctx.falseExpr - return state.boundedArrayGuard(array, type, maximumLength = SOURCE_ARRAY_MODEL_CAPACITY - additionalSlots) + val capacity = ownSlotCapacity(state, array, type, allowLargerMap) + return state.boundedArrayGuard(array, type, maximumLength = capacity - additionalSlots) } - fun prepareOwnSlots(state: TsState, inputs: List>): TsUnknownCallModelExecution? { + fun prepareOwnSlots(state: TsState, inputs: List>): TsUnknownCallModelExecution? = + prepareOwnSlots(state, inputs, allowLargerMap = false) + + fun prepareMapOwnSlots(state: TsState, inputs: List>): TsUnknownCallModelExecution? = + prepareOwnSlots(state, inputs, allowLargerMap = true) + + private fun prepareOwnSlots( + state: TsState, + inputs: List>, + allowLargerMap: Boolean, + ): TsUnknownCallModelExecution? { val array = inputs.single() as? UConcreteHeapRef ?: return null val type = state.arrayStorageType(array, EtsArrayType(EtsUnknownType, dimensions = 1)) as? EtsArrayType ?: return null @@ -52,7 +71,8 @@ internal object TsArraySlotPrimitives { val hasSlotProof = hasKnownSlots || state.hasDenseArrayShape(array, type) if (!hasSlotProof) return null - val guard = state.boundedArrayGuard(array, type, maximumLength = SOURCE_ARRAY_MODEL_CAPACITY) + val capacity = ownSlotCapacity(state, array, type, allowLargerMap) + val guard = state.boundedArrayGuard(array, type, maximumLength = capacity) val successor = TsUnknownCallModelSuccessor( guard = guard, completion = TsUnknownCallModelCompletion.Normal { @@ -71,6 +91,18 @@ internal object TsArraySlotPrimitives { ) } + private fun ownSlotCapacity( + state: TsState, + array: UConcreteHeapRef, + type: EtsArrayType, + allowLargerMap: Boolean, + ): Int { + if (!allowLargerMap || array !in state.knownArrayPropertyPresence) return SOURCE_ARRAY_MODEL_CAPACITY + + val length = state.memory.read(mkArrayLengthLValue(array, type)) + return if (length is KBitVec32Value) MAX_CONCRETE_MAP_LENGTH else SOURCE_ARRAY_MODEL_CAPACITY + } + fun hasOwnSlot(state: TsState, inputs: List>): TsUnknownCallModelExecution? = with(state.ctx) { val array = inputs[0] as? UConcreteHeapRef ?: return null val number = inputs[1].takeIf { it.sort == fp64Sort }?.asExpr(fp64Sort) ?: return null diff --git a/usvm-ts/src/main/resources/org/usvm/machine/call/models/ArrayModels.ts b/usvm-ts/src/main/resources/org/usvm/machine/call/models/ArrayModels.ts index b717a4ecb6..5707e49305 100644 --- a/usvm-ts/src/main/resources/org/usvm/machine/call/models/ArrayModels.ts +++ b/usvm-ts/src/main/resources/org/usvm/machine/call/models/ArrayModels.ts @@ -5,6 +5,8 @@ declare class ArrayModelPrimitives { static elementString(value: any): string; static requireDense(receiver: any[]): void; static prepareOwnSlots(receiver: any[]): void; + static prepareMapOwnSlots(receiver: any[]): void; + static allocateMapOutput(length: number): any[]; static hasOwnSlot(receiver: any[], index: number): boolean; } @@ -71,9 +73,9 @@ export class ArrayModels { } static map(receiver: any[], callback: (value: any, index: number, array: any[]) => any): any[] { - ArrayModelPrimitives.prepareOwnSlots(receiver); + ArrayModelPrimitives.prepareMapOwnSlots(receiver); const length = receiver.length; - const result = ArrayModelPrimitives.allocate(length); + const result = ArrayModelPrimitives.allocateMapOutput(length); let index = 0; while (index < length) { if (ArrayModelPrimitives.hasOwnSlot(receiver, index)) { diff --git a/usvm-ts/src/test/kotlin/org/usvm/machine/call/MapCapacityTest.kt b/usvm-ts/src/test/kotlin/org/usvm/machine/call/MapCapacityTest.kt new file mode 100644 index 0000000000..65497f52dc --- /dev/null +++ b/usvm-ts/src/test/kotlin/org/usvm/machine/call/MapCapacityTest.kt @@ -0,0 +1,118 @@ +package org.usvm.machine.call + +import org.jacodb.ets.utils.loadEtsProjectAutoConvert +import org.junit.jupiter.api.io.TempDir +import org.usvm.PathSelectionStrategy +import org.usvm.StateCollectionStrategy +import org.usvm.api.TsTestValue +import org.usvm.machine.TsInterpreterObserver +import org.usvm.machine.TsMachine +import org.usvm.machine.TsOptions +import org.usvm.util.TsMethodTestRunner +import org.usvm.util.TsTestResolver +import org.usvm.util.assertNodeReplay +import org.usvm.util.getResourcePath +import java.nio.file.Path +import kotlin.io.path.readText +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertIs +import kotlin.test.assertTrue + +class MapCapacityTest : TsMethodTestRunner() { + private val source = getResourcePath("/models/map-capacity") + override val scene = loadEtsProjectAutoConvert(source, useArkAnalyzerTypeInference = null) + + @TempDir + lateinit var directory: Path + + init { + options = options.copy( + pathSelectionStrategies = listOf(PathSelectionStrategy.BFS), + stateCollectionStrategy = StateCollectionStrategy.ALL, + stopOnCoverage = 0, + throwExceptionOnStepFailure = true, + ) + } + + @Test + fun `large known arrays preserve holes, explicit undefined, and callback changes`() { + for ((method, applicationCount) in mapOf("sparseMutationAndUndefined" to 2, "atCapacity" to 1)) { + val (numbers, applications, _) = analyze(method) + + assertEquals(setOf(1.0), numbers, method) + assertEquals(applicationCount, applications.count { it == MAP_ID }, method) + } + } + + @Test + fun `larger bound stays confined to built-in map`() { + val (customReturn, customApplications, _) = analyze("customMap") + assertEquals(setOf(1.0), customReturn) + assertTrue(customApplications.isEmpty()) + + for (method in listOf("aboveCapacity", "unrelatedArrayRoutine")) { + val (numbers, applications, events) = analyze(method) + + assertTrue(numbers.isEmpty(), method) + assertTrue(applications.isEmpty(), method) + assertTrue(events.any { it.outcome == TsUnknownCallOutcome.PATH_STOPPED }, method) + } + } + + @Test + fun `Node confirms fixture results`() { + val methods = listOf( + "sparseMutationAndUndefined", + "atCapacity", + "aboveCapacity", + "customMap", + "unrelatedArrayRoutine", + ) + val assertions = methods.joinToString(separator = "\n") { method -> + "if (MapCapacityCases.$method() !== 1) throw Error('$method');" + } + assertNodeReplay( + source = source.resolve("MapCapacityCases.ts").readText() + "\n" + assertions, + directory = directory, + name = "native-map-capacity", + timeoutMessage = "Native map capacity check timed out", + ) + } + + private fun analyze(methodName: String): Triple, List, List> { + val method = getMethod(methodName, className = "MapCapacityCases") + val events = mutableListOf() + val observer = object : TsInterpreterObserver { + override fun onUnknownCall(event: TsUnknownCallEvent) { + events += event + } + } + val tsOptions = TsOptions( + eraseTypeAssertions = true, + unknownCallModelSelection = TsUnknownCallModelSelection.Only(setOf(MAP_ID, "ts.array.reverse")), + unknownCallFallback = TsResidualCallPolicy.STOP_PATH, + ) + + val outcome = TsMachine( + scene = scene, + options = options, + tsOptions = tsOptions, + observer = observer, + ).use { machine -> + machine.analyzeWithMetadata(methods = listOf(method)) + } + + assertFalse(outcome.engineFailed, methodName) + val numbers = outcome.states.map { state -> + assertIs(TsTestResolver().resolve(method, state).returnValue).number + }.toSet() + val applications = events.mapNotNull { (it.decision as? TsUnknownCallDecision.ModelApplied)?.modelId } + return Triple(numbers, applications, events) + } + + private companion object { + const val MAP_ID = "ts.array.map" + } +} diff --git a/usvm-ts/src/test/kotlin/org/usvm/machine/call/TsUnknownCallModelCatalogTest.kt b/usvm-ts/src/test/kotlin/org/usvm/machine/call/TsUnknownCallModelCatalogTest.kt index 2975b7f704..20bfa916ba 100644 --- a/usvm-ts/src/test/kotlin/org/usvm/machine/call/TsUnknownCallModelCatalogTest.kt +++ b/usvm-ts/src/test/kotlin/org/usvm/machine/call/TsUnknownCallModelCatalogTest.kt @@ -195,10 +195,12 @@ class TsUnknownCallModelCatalogTest { "ts.array.pop", "ts.array.primitive.allocate", "ts.array.primitive.allocateLike", + "ts.array.primitive.allocateMapOutput", "ts.array.primitive.allocateStrings", "ts.array.primitive.elementString", "ts.array.primitive.grow", "ts.array.primitive.hasOwnSlot", + "ts.array.primitive.prepareMapOwnSlots", "ts.array.primitive.prepareOwnSlots", "ts.array.primitive.requireDense", "ts.array.primitive.truncateDense", @@ -275,6 +277,21 @@ class TsUnknownCallModelCatalogTest { assertTrue(TsBuiltInUnknownCallModels.catalog(TsUnknownCallModelSelection.Only(emptySet())).modelIds.isEmpty()) } + @Test + fun `array map selects its own slot and output helpers`() { + val selection = TsUnknownCallModelSelection.Only(setOf("ts.array.map")) + val expected = listOf( + "ts.array.map", + "ts.array.primitive.allocateMapOutput", + "ts.array.primitive.hasOwnSlot", + "ts.array.primitive.prepareMapOwnSlots", + ) + + val catalog = TsBuiltInUnknownCallModels.catalog(selection) + + assertEquals(expected, catalog.modelIds) + } + @Test fun `array and string built in model families are discovered`() { val modelIds = TsBuiltInUnknownCallModels.catalog().modelIds diff --git a/usvm-ts/src/test/resources/models/map-capacity/MapCapacityCases.ts b/usvm-ts/src/test/resources/models/map-capacity/MapCapacityCases.ts new file mode 100644 index 0000000000..3586bf0203 --- /dev/null +++ b/usvm-ts/src/test/resources/models/map-capacity/MapCapacityCases.ts @@ -0,0 +1,67 @@ +class ProjectCollection { + map(value: number): number { + return value + 1; + } +} + +export class MapCapacityCases { + static sparseMutationAndUndefined(): number { + const values = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, undefined]; + delete values[1]; + const observed = { count: 0, sawUndefined: false }; + const result = values.map((value, index, receiver) => { + if (receiver !== values || index === 1 || index === 2) throw 101; + if (index === 0) delete receiver[2]; + observed.count++; + return value === undefined ? undefined : value + index; + }); + + result.map((value, index) => { + if (index === 1 || index === 2) throw 102; + if (index === 16 && value === undefined) observed.sawUndefined = true; + return value; + }); + + return result.length === 17 && result[0] === 3 && result[3] === 12 && + observed.count === 15 && observed.sawUndefined ? 1 : 0; + } + + static atCapacity(): number { + const values = [ + 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, + ]; + const result = values.map((value, index) => value + index); + return result.length === 64 && result[0] === 3 && result[63] === 74 ? 1 : 0; + } + + static aboveCapacity(): number { + const values = [ + 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 11, + ]; + const result = values.map((value, index) => value + index); + return result.length === 65 && result[64] === 75 ? 1 : 0; + } + + static customMap(): number { + const collection = new ProjectCollection(); + return collection.map(1) === 2 ? 1 : 0; + } + + static unrelatedArrayRoutine(): number { + const values = [ + 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, + ]; + const reversed = values.reverse(); + return reversed === values && values[0] === 11 && values[63] === 3 ? 1 : 0; + } +}