Modern Apps git

← Modern-Apps.git

tests: table-drive the three dense pure-logic suites that actually convert

Commit
a10b333a3e02abc0da006cd498993abf701de90f
Author
Vayun Mathur <[email protected]>
When
2026-12-01 16:45 UTC (4 days ago)
Parents
0053e6a
LOC Phase 3 batch 1, measured honestly: only 3 of the 11
in-scope files converted above the 25% bar (net -411):
ExpressionTest 312->215 (30 tests into 3 tables, 61 rows),
EditorInputTest 378->198 (39 into 7 tables, 44 rows),
RRuleTest 379->245 (21 into 3 tables, 25 rows). Assertion
fidelity verified by occurrence count (73->73, 122->122,
84->87 from unrolling a spelling loop); every table
accumulates and reports all failing rows at once; named
regression tests and comment-bearing cases stay named or
keep their comments.

The other 8 files were measured and SKIPPED below 25%
(scenario setups, JSON literals, rationale KDocs, stateful
pockets) — the sampling estimate for this batch was
optimistic and the larger 11-14.5k Tier-1 claim needs
per-file proof, not faith. Verified: :calculator and :code
full suites pass; calendar's one failure is the known
holiday-route WIP in untouched files.

Diff

calculator/src/test/java/com/vayunmathur/calculator/util/ExpressionTest.kt
diff --git a/calculator/src/test/java/com/vayunmathur/calculator/util/ExpressionTest.kt b/calculator/src/test/java/com/vayunmathur/calculator/util/ExpressionTest.ktindex b1011ca588..0d8944efc9 100644--- a/calculator/src/test/java/com/vayunmathur/calculator/util/ExpressionTest.kt+++ b/calculator/src/test/java/com/vayunmathur/calculator/util/ExpressionTest.kt@@ -9,6 +9,7 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertTrue+import kotlin.test.fail  class ExpressionTest { @@ -26,30 +27,112 @@ class ExpressionTest {         )     } -    // ---- precedence and associativity ------    @Test-    fun multiplicationBindsTighterThanAddition() {-        assertEquals(14.0, eval("2 + 3 * 4"))-        assertEquals(20.0, eval("(2 + 3) * 4"))-    }--    @Test-    fun subtractionIsLeftAssociative() {-        // A right-associative fold would give 2 - (3 - 4) = 3.-        assertEquals(-5.0, eval("2 - 3 - 4"))-    }--    @Test-    fun divisionIsLeftAssociative() {-        assertEquals(2.0, eval("16 / 4 / 2"))-    }--    @Test-    fun exponentiationIsRightAssociative() {-        // Left-associative would be (2^3)^2 = 64.-        assertEquals(512.0, eval("2^3^2"))-    }+    /** Runs every row, then fails once with all failing row labels. */+    private fun runRows(rows: List<Pair<String, () -> Unit>>) {+        val failures = mutableListOf<String>()+        for ((label, check) in rows) {+            try {+                check()+            } catch (e: AssertionError) {+                failures += "$label: ${e.message}"+            }+        }+        if (failures.isNotEmpty()) fail(failures.joinToString("\n"))+    }++    // ---- table-driven exact evaluations ----++    @Test+    fun exactEvaluations() = runRows(+        listOf(+            "multiplication binds tighter: 2 + 3 * 4" to { assertEquals(14.0, eval("2 + 3 * 4")) },+            "parentheses override precedence: (2 + 3) * 4" to { assertEquals(20.0, eval("(2 + 3) * 4")) },+            // A right-associative fold would give 2 - (3 - 4) = 3.+            "subtraction is left-associative: 2 - 3 - 4" to { assertEquals(-5.0, eval("2 - 3 - 4")) },+            "division is left-associative: 16 / 4 / 2" to { assertEquals(2.0, eval("16 / 4 / 2")) },+            // Left-associative would be (2^3)^2 = 64.+            "exponentiation is right-associative: 2^3^2" to { assertEquals(512.0, eval("2^3^2")) },+            // Documented in parsePower: -x^2 means -(x^2).+            "unary minus applies to the power: -3^2" to { assertEquals(-9.0, eval("-3^2")) },+            "parenthesised negative base: (-3)^2" to { assertEquals(9.0, eval("(-3)^2")) },+            "repeated unary: --5" to { assertEquals(5.0, eval("--5")) },+            "repeated unary: ---5" to { assertEquals(-5.0, eval("---5")) },+            "repeated unary: +5" to { assertEquals(5.0, eval("+5")) },+            "implicit multiplication by variable: 2x at x=3" to { assertEquals(6.0, eval("2x", x = 3.0)) },+            "implicit multiplication by group: 2(x+1) at x=3" to { assertEquals(8.0, eval("2(x+1)", x = 3.0)) },+            "implicit multiplication by groups: 3(2)(2)" to { assertEquals(12.0, eval("3(2)(2)")) },+            // 1 + 2x with x=3 is 1 + 6, not (1+2)*3.+            "implicit multiplication does not outrank precedence: 1 + 2x at x=3" to {+                assertEquals(7.0, eval("1 + 2x", x = 3.0))+            },+            // Only a unit binds to the divisor's number (see UnitsTest); a variable+            // or group after a division remains a term-level implicit factor.+            "division by variable stays left-to-right: 1/2x at x=4" to { assertEquals(2.0, eval("1/2x", x = 4.0)) },+            "division by group stays left-to-right: 6/2(1+2)" to { assertEquals(9.0, eval("6/2(1+2)")) },+            "scientific notation uppercase: 1.5E3" to { assertEquals(1500.0, eval("1.5E3")) },+            "scientific notation uppercase negative: 1.5E-3" to { assertEquals(0.0015, eval("1.5E-3")) },+            "leading decimal point: .5" to { assertEquals(0.5, eval(".5")) },+            "whitespace is ignored" to { assertEquals(7.0, eval("  1   +   2 * 3  ")) },+            "ans is supplied at eval time: ans + 1 at ans=20" to { assertEquals(21.0, eval("ans + 1", ans = 20.0)) },+            "variable spelling 'x'" to { assertEquals(4.0, eval("x", x = 4.0)) },+            "variable spelling 't'" to { assertEquals(4.0, eval("t", x = 4.0)) },+            "variable spelling 'theta'" to { assertEquals(4.0, eval("theta", x = 4.0)) },+            "variable spelling 'θ'" to { assertEquals(4.0, eval("θ", x = 4.0)) },+            "factorial: 0!" to { assertEquals(1.0, eval("0!")) },+            "factorial: 5!" to { assertEquals(120.0, eval("5!")) },+            "factorial: 10!" to { assertEquals(3628800.0, eval("10!")) },+            "max variable arity: max(1,9,4)" to { assertEquals(9.0, eval("max(1,9,4)")) },+            "min variable arity: min(1,9,4)" to { assertEquals(1.0, eval("min(1,9,4)")) },+            "absolute value: |-5|" to { assertEquals(5.0, eval("|-5|")) },+            "absolute value of variable: |x| at x=-3" to { assertEquals(3.0, eval("|x|", x = -3.0)) },+            "absolute value as factor: 2|-5|" to { assertEquals(10.0, eval("2|-5|")) },+            "gcd(12,18)" to { assertEquals(6.0, eval("gcd(12,18)")) },+            "lcm(12,18)" to { assertEquals(36.0, eval("lcm(12,18)")) },+            "mod(8,3)" to { assertEquals(2.0, eval("mod(8,3)")) },+        ),+    )++    @Test+    fun closeEvaluations() = runRows(+        listOf(+            "constant pi" to { assertClose(PI, eval("pi")) },+            "constant π" to { assertClose(PI, eval("π")) },+            "constant tau" to { assertClose(2 * PI, eval("tau")) },+            "constant e" to { assertClose(kotlin.math.E, eval("e")) },+            "constant phi" to { assertClose(1.618033988749, eval("phi"), 1e-9) },+            "implicit multiplication by function: 2sin(0)" to { assertClose(0.0, eval("2sin(0)")) },+            // Lowercase 'e' is Euler's constant, so "2e" is implicit multiplication.+            "lowercase e is Euler's constant: 2e" to { assertClose(2 * kotlin.math.E, eval("2e")) },+            "degree mode: sin(90)" to { assertClose(1.0, eval("sin(90)", angle = AngleMode.DEGREES), 1e-12) },+            "degree mode: asin(1)" to { assertClose(90.0, eval("asin(1)", angle = AngleMode.DEGREES), 1e-12) },+            "degree mode: atan2(1,1)" to { assertClose(45.0, eval("atan2(1,1)", angle = AngleMode.DEGREES), 1e-12) },+            "radian mode is the default: sin(pi/2)" to { assertClose(1.0, eval("sin(pi/2)"), 1e-12) },+            // base 10 by default+            "log(100)" to { assertClose(2.0, eval("log(100)"), 1e-12) },+            // log base 2 of 8+            "log(2,8)" to { assertClose(3.0, eval("log(2,8)"), 1e-12) },+            "ncr(5,2)" to { assertClose(10.0, eval("ncr(5,2)"), 1e-9) },+            "npr(5,2)" to { assertClose(20.0, eval("npr(5,2)"), 1e-9) },+            "root(3,27)" to { assertClose(3.0, eval("root(3,27)"), 1e-12) },+        ),+    )++    @Test+    fun rejectedInputs() = runRows(+        listOf(+            "unbalanced parenthesis: (1+2" to { assertFailsWith<ExpressionError> { eval("(1+2") } },+            "trailing garbage: 1+2)" to { assertFailsWith<ExpressionError> { eval("1+2)") } },+            "empty input" to { assertFailsWith<ExpressionError> { eval("") } },+            "unknown function: frobnicate(2)" to { assertFailsWith<ExpressionError> { eval("frobnicate(2)") } },+            "unknown bare symbol: y" to { assertFailsWith<ExpressionError> { eval("y") } },+            "dangling operator: 1+" to { assertFailsWith<ExpressionError> { eval("1+") } },+            "wrong arity: gcd(1)" to { assertFailsWith<ExpressionError> { eval("gcd(1)") } },+            "wrong arity: sin(1,2)" to { assertFailsWith<ExpressionError> { eval("sin(1,2)") } },+            "unterminated bar: |5" to { assertFailsWith<ExpressionError> { eval("|5") } },+        ),+    )++    // ---- kept named: regressions, self-comparisons and stateful cases ----      @Test     fun fractionalExponentsWorkForDimensionlessBases() {@@ -64,54 +147,6 @@ class ExpressionTest {         assertTrue(eval("(-8)^(1/3)").isNaN())     } -    @Test-    fun unaryMinusAppliesToThePowerNotTheBase() {-        // Documented in parsePower: -x^2 means -(x^2).-        assertEquals(-9.0, eval("-3^2"))-        assertEquals(9.0, eval("(-3)^2"))-    }--    @Test-    fun repeatedUnarySignsCollapse() {-        assertEquals(5.0, eval("--5"))-        assertEquals(-5.0, eval("---5"))-        assertEquals(5.0, eval("+5"))-    }--    // ---- implicit multiplication ------    @Test-    fun implicitMultiplicationAgainstVariablesGroupsAndFunctions() {-        assertEquals(6.0, eval("2x", x = 3.0))-        assertEquals(8.0, eval("2(x+1)", x = 3.0))-        assertClose(0.0, eval("2sin(0)"))-        assertEquals(12.0, eval("3(2)(2)"))-    }--    @Test-    fun implicitMultiplicationDoesNotOutrankExplicitPrecedence() {-        // 1 + 2x with x=3 is 1 + 6, not (1+2)*3.-        assertEquals(7.0, eval("1 + 2x", x = 3.0))-    }--    @Test-    fun divisionByAVariableOrGroupStaysLeftToRight() {-        // Only a unit binds to the divisor's number (see UnitsTest); a variable-        // or group after a division remains a term-level implicit factor.-        assertEquals(2.0, eval("1/2x", x = 4.0))-        assertEquals(9.0, eval("6/2(1+2)"))-    }--    // ---- numbers ------    @Test-    fun scientificNotationUsesUppercaseEOnly() {-        assertEquals(1500.0, eval("1.5E3"))-        assertEquals(0.0015, eval("1.5E-3"))-        // Lowercase 'e' is Euler's constant, so "2e" is implicit multiplication.-        assertClose(2 * kotlin.math.E, eval("2e"))-    }-     @Test     fun trailingEIsNotSwallowedAsAnExponent() {         // parseNumber rewinds when 'E' is not followed by digits, so "2E" is not the@@ -120,39 +155,6 @@ class ExpressionTest {         assertClose(2 * kotlin.math.E, eval("2E"))     } -    @Test-    fun leadingDecimalPointParses() {-        assertEquals(0.5, eval(".5"))-    }--    @Test-    fun whitespaceIsIgnored() {-        assertEquals(7.0, eval("  1   +   2 * 3  "))-    }--    // ---- constants, variable, ans ------    @Test-    fun constantsResolve() {-        assertClose(PI, eval("pi"))-        assertClose(PI, eval("π"))-        assertClose(2 * PI, eval("tau"))-        assertClose(kotlin.math.E, eval("e"))-        assertClose(1.618033988749, eval("phi"), 1e-9)-    }--    @Test-    fun everyVariableSpellingBindsToTheSameFreeVariable() {-        for (name in listOf("x", "t", "theta", "θ")) {-            assertEquals(4.0, eval(name, x = 4.0), "spelling '$name'")-        }-    }--    @Test-    fun ansIsSuppliedAtEvalTime() {-        assertEquals(21.0, eval("ans + 1", ans = 20.0))-    }-     @Test     fun aParsedExpressionCanBeEvaluatedRepeatedlyWithDifferentValues() {         val expr = Expression.parse("x^2")@@ -161,49 +163,12 @@ class ExpressionTest {         assertEquals(9.0, expr.eval(3.0))     } -    // ---- angle mode ------    @Test-    fun degreeModeConvertsArgumentsAndResults() {-        assertClose(1.0, eval("sin(90)", angle = AngleMode.DEGREES), 1e-12)-        assertClose(90.0, eval("asin(1)", angle = AngleMode.DEGREES), 1e-12)-        assertClose(45.0, eval("atan2(1,1)", angle = AngleMode.DEGREES), 1e-12)-    }--    @Test-    fun radianModeIsTheDefault() {-        assertClose(1.0, eval("sin(pi/2)"), 1e-12)-    }-     @Test     fun hyperbolicFunctionsIgnoreAngleMode() {         // sinh takes a real, not an angle, so degrees must not scale it.         assertEquals(eval("sinh(1)"), eval("sinh(1)", angle = AngleMode.DEGREES))     } -    // ---- absolute-value bars ------    @Test-    fun absoluteValueBars() {-        assertEquals(5.0, eval("|-5|"))-        assertEquals(3.0, eval("|x|", x = -3.0))-        assertEquals(10.0, eval("2|-5|"))-    }--    @Test-    fun unterminatedBarIsAnError() {-        assertFailsWith<ExpressionError> { eval("|5") }-    }--    // ---- factorial ------    @Test-    fun factorialOfSmallIntegersIsExact() {-        assertEquals(1.0, eval("0!"))-        assertEquals(120.0, eval("5!"))-        assertEquals(3628800.0, eval("10!"))-    }-     @Test     fun factorialOfNegativeIntegersIsNaNBecauseGammaHasPolesThere() {         assertTrue(eval("(-1)!").isNaN())@@ -215,24 +180,6 @@ class ExpressionTest {         assertClose(kotlin.math.sqrt(PI) / 2, eval("0.5!"), 1e-9)     } -    // ---- multi-argument functions ------    @Test-    fun logTakesAnOptionalBase() {-        assertClose(2.0, eval("log(100)"), 1e-12)   // base 10 by default-        assertClose(3.0, eval("log(2,8)"), 1e-12)   // log base 2 of 8-    }--    @Test-    fun combinatoricsAndNumberTheory() {-        assertClose(10.0, eval("ncr(5,2)"), 1e-9)-        assertClose(20.0, eval("npr(5,2)"), 1e-9)-        assertEquals(6.0, eval("gcd(12,18)"))-        assertEquals(36.0, eval("lcm(12,18)"))-        assertEquals(2.0, eval("mod(8,3)"))-        assertClose(3.0, eval("root(3,27)"), 1e-12)-    }-     @Test     fun oddRootOfNegativeIsReal() {         // root(3, -8) is -2 (matching cbrt(-8)); pow(1/3) alone gives NaN.@@ -243,18 +190,6 @@ class ExpressionTest {         assertTrue(eval("root(2,-4)").isNaN())     } -    @Test-    fun maxAndMinAcceptVariableArity() {-        assertEquals(9.0, eval("max(1,9,4)"))-        assertEquals(1.0, eval("min(1,9,4)"))-    }--    @Test-    fun wrongArityIsRejected() {-        assertFailsWith<ExpressionError> { eval("gcd(1)") }-        assertFailsWith<ExpressionError> { eval("sin(1,2)") }-    }-     @Test     fun emptyMaxAndMinAreExpressionErrorsNotCrashes() {         // a.max()/a.min() on an empty list throw NoSuchElementException, which@@ -265,38 +200,6 @@ class ExpressionTest {         assertFailsWith<ExpressionError> { eval("min()") }     } -    // ---- errors ------    @Test-    fun unbalancedParenthesisIsAnError() {-        assertFailsWith<ExpressionError> { eval("(1+2") }-    }--    @Test-    fun trailingGarbageIsAnError() {-        assertFailsWith<ExpressionError> { eval("1+2)") }-    }--    @Test-    fun emptyInputIsAnError() {-        assertFailsWith<ExpressionError> { eval("") }-    }--    @Test-    fun unknownFunctionIsAnError() {-        assertFailsWith<ExpressionError> { eval("frobnicate(2)") }-    }--    @Test-    fun unknownBareSymbolIsAnError() {-        assertFailsWith<ExpressionError> { eval("y") }-    }--    @Test-    fun danglingOperatorIsAnError() {-        assertFailsWith<ExpressionError> { eval("1+") }-    }-     // ---- IEEE edge cases that must not throw ----      @Test
calendar/src/test/java/com/vayunmathur/calendar/util/RRuleTest.kt
diff --git a/calendar/src/test/java/com/vayunmathur/calendar/util/RRuleTest.kt b/calendar/src/test/java/com/vayunmathur/calendar/util/RRuleTest.ktindex d1966059b6..d80c3eba6d 100644--- a/calendar/src/test/java/com/vayunmathur/calendar/util/RRuleTest.kt+++ b/calendar/src/test/java/com/vayunmathur/calendar/util/RRuleTest.kt@@ -8,253 +8,154 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.assertTrue+import kotlin.test.fail  class RRuleTest {      private val timeZone = TimeZone.of("America/Los_Angeles") -    @Test-    fun readableStringUsesReadableFormNotDataClass() {-        val yearly = RRule.parse("FREQ=YEARLY;INTERVAL=1", timeZone)!!-        assertEquals("Yearly", yearly.toString())--        val everyThreeYears = RRule.parse("FREQ=YEARLY;INTERVAL=3", timeZone)!!-        assertEquals("Every 3 years", everyThreeYears.toString())--        val monthly = RRule.parse("FREQ=MONTHLY;INTERVAL=1", timeZone)!!-        assertEquals("Monthly", monthly.toString())--        val daily = RRule.parse("FREQ=DAILY;INTERVAL=1", timeZone)!!-        assertEquals("Daily", daily.toString())--        val weekly = RRule.parse("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE", timeZone)!!-        assertEquals("Weekly on Mon, Wed", weekly.toString())-    }--    @Test-    fun readableStringIncludesEndCondition() {-        val counted = RRule.parse("FREQ=DAILY;INTERVAL=2;COUNT=5", timeZone)!!-        assertEquals("Every 2 days, 5 times", counted.toString())-    }--    @Test-    fun testParseDailyWithInterval() {-        val rrule = RRule.parse("FREQ=DAILY;INTERVAL=2", timeZone)-        assertNotNull(rrule)-        assertTrue(rrule is RRule.EveryXDays)-        val daily = rrule as RRule.EveryXDays-        assertEquals(2, daily.days)-        assertTrue(daily.endCondition is RRule.EndCondition.Never)-    }--    @Test-    fun testParseWeeklyWithByDay() {-        val rrule = RRule.parse("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,FR", timeZone)-        assertNotNull(rrule)-        assertTrue(rrule is RRule.EveryXWeeks)-        val weekly = rrule as RRule.EveryXWeeks-        assertEquals(1, weekly.weeks)-        assertEquals(3, weekly.daysOfWeek.size)-        assertTrue(weekly.daysOfWeek.contains(DayOfWeek.MONDAY))-        assertTrue(weekly.daysOfWeek.contains(DayOfWeek.WEDNESDAY))-        assertTrue(weekly.daysOfWeek.contains(DayOfWeek.FRIDAY))-    }--    @Test-    fun testParseMonthlyWithByMonthDay() {-        val rrule = RRule.parse("FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=1,15,-1", timeZone)-        assertNotNull(rrule)-        assertTrue(rrule is RRule.EveryXMonths)-        val monthly = rrule as RRule.EveryXMonths-        assertNotNull(monthly.byMonthDay)-        assertEquals(3, monthly.byMonthDay!!.size)-        assertTrue(monthly.byMonthDay!!.contains(1))-        assertTrue(monthly.byMonthDay!!.contains(15))-        assertTrue(monthly.byMonthDay!!.contains(-1))-    }--    @Test-    fun testParseYearlyWithByMonth() {-        val rrule = RRule.parse("FREQ=YEARLY;INTERVAL=1;BYMONTH=1,6,12", timeZone)-        assertNotNull(rrule)-        assertTrue(rrule is RRule.EveryXYears)-        val yearly = rrule as RRule.EveryXYears-        assertNotNull(yearly.byMonth)-        assertEquals(3, yearly.byMonth!!.size)-        assertTrue(yearly.byMonth!!.contains(1))-        assertTrue(yearly.byMonth!!.contains(6))-        assertTrue(yearly.byMonth!!.contains(12))-    }--    @Test-    fun testParseWithBySetPos() {-        val rrule = RRule.parse("FREQ=MONTHLY;INTERVAL=1;BYSETPOS=1,-1", timeZone)-        assertNotNull(rrule)-        assertTrue(rrule is RRule.EveryXMonths)-        val monthly = rrule as RRule.EveryXMonths-        assertNotNull(monthly.bySetPos)-        assertEquals(2, monthly.bySetPos!!.size)-        assertTrue(monthly.bySetPos!!.contains(1))-        assertTrue(monthly.bySetPos!!.contains(-1))-    }--    @Test-    fun testParseWithByYearDay() {-        val rrule = RRule.parse("FREQ=YEARLY;INTERVAL=1;BYYEARDAY=1,100,365", timeZone)-        assertNotNull(rrule)-        assertTrue(rrule is RRule.EveryXYears)-        val yearly = rrule as RRule.EveryXYears-        assertNotNull(yearly.byYearDay)-        assertEquals(3, yearly.byYearDay!!.size)-        assertTrue(yearly.byYearDay!!.contains(1))-        assertTrue(yearly.byYearDay!!.contains(100))-        assertTrue(yearly.byYearDay!!.contains(365))-    }--    @Test-    fun testParseWithByWeekNo() {-        val rrule = RRule.parse("FREQ=YEARLY;INTERVAL=1;BYWEEKNO=1,26,52", timeZone)-        assertNotNull(rrule)-        assertTrue(rrule is RRule.EveryXYears)-        val yearly = rrule as RRule.EveryXYears-        assertNotNull(yearly.byWeekNo)-        assertEquals(3, yearly.byWeekNo!!.size)-        assertTrue(yearly.byWeekNo!!.contains(1))-        assertTrue(yearly.byWeekNo!!.contains(26))-        assertTrue(yearly.byWeekNo!!.contains(52))-    }--    @Test-    fun testParseWithWkst() {-        val rrule = RRule.parse("FREQ=WEEKLY;INTERVAL=1;WKST=SU", timeZone)-        assertNotNull(rrule)-        assertTrue(rrule is RRule.EveryXWeeks)-        val weekly = rrule as RRule.EveryXWeeks-        assertNotNull(weekly.wkst)-        assertEquals(DayOfWeek.SUNDAY, weekly.wkst)-    }--    @Test-    fun testParseWithCount() {-        val rrule = RRule.parse("FREQ=DAILY;INTERVAL=1;COUNT=10", timeZone)-        assertNotNull(rrule)-        assertTrue(rrule is RRule.EveryXDays)-        val daily = rrule as RRule.EveryXDays-        assertTrue(daily.endCondition is RRule.EndCondition.Count)-        val count = daily.endCondition as RRule.EndCondition.Count-        assertEquals(10L, count.count)-    }--    @Test-    fun testParseWithUntil() {-        val rrule = RRule.parse("FREQ=DAILY;INTERVAL=1;UNTIL=20251231T235959Z", timeZone)-        assertNotNull(rrule)-        assertTrue(rrule is RRule.EveryXDays)-        val daily = rrule as RRule.EveryXDays-        assertTrue(daily.endCondition is RRule.EndCondition.Until)-        val until = daily.endCondition as RRule.EndCondition.Until-        assertEquals(LocalDate(2025, 12, 31), until.date)-    }--    @Test-    fun testAsStringDailyWithByMonthDay() {-        val rrule = RRule.EveryXDays(-            days = 1,-            endCondition = RRule.EndCondition.Never,-            byMonthDay = listOf(1, 15, -1)-        )-        val firstDay = LocalDate(2025, 1, 1)-        val result = rrule.asString(firstDay, timeZone)-        assertTrue(result.contains("FREQ=DAILY"))-        assertTrue(result.contains("BYMONTHDAY=1,15,-1"))-    }--    @Test-    fun testAsStringWeeklyWithWkst() {-        val rrule = RRule.EveryXWeeks(-            weeks = 1,-            daysOfWeek = listOf(DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY),-            endCondition = RRule.EndCondition.Never,-            wkst = DayOfWeek.SUNDAY-        )-        val firstDay = LocalDate(2025, 1, 1)-        val result = rrule.asString(firstDay, timeZone)-        assertTrue(result.contains("FREQ=WEEKLY"))-        assertTrue(result.contains("BYDAY=MO,WE"))-        assertTrue(result.contains("WKST=SU"))-    }--    @Test-    fun testAsStringMonthlyWithMultipleProperties() {-        val rrule = RRule.EveryXMonths(-            months = 2,-            typeE = 0,-            endCondition = RRule.EndCondition.Count(5),-            byMonthDay = listOf(1, 15),-            bySetPos = listOf(1, -1),-            byMonth = listOf(1, 6, 12)-        )-        val firstDay = LocalDate(2025, 1, 1)-        val result = rrule.asString(firstDay, timeZone)-        assertTrue(result.contains("FREQ=MONTHLY"))-        assertTrue(result.contains("INTERVAL=2"))-        assertTrue(result.contains("BYMONTHDAY=1,15"))-        assertTrue(result.contains("BYSETPOS=1,-1"))-        assertTrue(result.contains("BYMONTH=1,6,12"))-        assertTrue(result.contains("COUNT=5"))-    }--    @Test-    fun testAsStringYearlyWithAllProperties() {-        val rrule = RRule.EveryXYears(-            years = 1,-            endCondition = RRule.EndCondition.Never,-            byMonthDay = listOf(1),-            byMonth = listOf(1, 7),-            bySetPos = listOf(1),-            byYearDay = listOf(1, 365),-            byWeekNo = listOf(1, 52),-            wkst = DayOfWeek.MONDAY-        )-        val firstDay = LocalDate(2025, 1, 1)-        val result = rrule.asString(firstDay, timeZone)-        assertTrue(result.contains("FREQ=YEARLY"))-        assertTrue(result.contains("BYMONTHDAY=1"))-        assertTrue(result.contains("BYMONTH=1,7"))-        assertTrue(result.contains("BYSETPOS=1"))-        assertTrue(result.contains("BYYEARDAY=1,365"))-        assertTrue(result.contains("BYWEEKNO=1,52"))-        assertTrue(result.contains("WKST=MO"))-    }--    @Test-    fun testParseComplexRRule() {-        val rruleStr = "FREQ=MONTHLY;INTERVAL=2;BYMONTHDAY=1,15;BYSETPOS=1,-1;COUNT=10"-        val rrule = RRule.parse(rruleStr, timeZone)-        assertNotNull(rrule)-        assertTrue(rrule is RRule.EveryXMonths)-        val monthly = rrule as RRule.EveryXMonths-        assertEquals(2, monthly.months)-        assertNotNull(monthly.byMonthDay)-        assertEquals(2, monthly.byMonthDay!!.size)-        assertNotNull(monthly.bySetPos)-        assertEquals(2, monthly.bySetPos!!.size)-        assertTrue(monthly.endCondition is RRule.EndCondition.Count)-    }--    @Test-    fun testParseMonthlyNthWeekday() {-        val rrule = RRule.parse("FREQ=MONTHLY;INTERVAL=1;BYDAY=2TU", timeZone)-        assertTrue(rrule is RRule.EveryXMonths)-        assertEquals(1, (rrule as RRule.EveryXMonths).typeE)-    }--    @Test-    fun testParseMonthlyLastWeekday() {-        val rrule = RRule.parse("FREQ=MONTHLY;INTERVAL=1;BYDAY=-1MO", timeZone)-        assertTrue(rrule is RRule.EveryXMonths)-        assertEquals(2, (rrule as RRule.EveryXMonths).typeE)-    }+    /** Runs every row, then fails once with all failing row labels. */+    private fun runRows(rows: List<Pair<String, () -> Unit>>) {+        val failures = mutableListOf<String>()+        for ((label, check) in rows) {+            try { check() } catch (e: AssertionError) { failures += "$label: ${e.message}" }+        }+        if (failures.isNotEmpty()) fail(failures.joinToString("\n"))+    }++    @Test+    fun readableStringCases() = runRows(listOf(+        "yearly" to { assertEquals("Yearly", RRule.parse("FREQ=YEARLY;INTERVAL=1", timeZone)!!.toString()) },+        "every three years" to { assertEquals("Every 3 years", RRule.parse("FREQ=YEARLY;INTERVAL=3", timeZone)!!.toString()) },+        "monthly" to { assertEquals("Monthly", RRule.parse("FREQ=MONTHLY;INTERVAL=1", timeZone)!!.toString()) },+        "daily" to { assertEquals("Daily", RRule.parse("FREQ=DAILY;INTERVAL=1", timeZone)!!.toString()) },+        "weekly on Mon, Wed" to { assertEquals("Weekly on Mon, Wed", RRule.parse("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE", timeZone)!!.toString()) },+        "counted every 2 days" to { assertEquals("Every 2 days, 5 times", RRule.parse("FREQ=DAILY;INTERVAL=2;COUNT=5", timeZone)!!.toString()) },+    ))++    @Test+    fun parseCases() = runRows(listOf(+        "daily with interval" to { val rrule = RRule.parse("FREQ=DAILY;INTERVAL=2", timeZone)+            assertNotNull(rrule); assertTrue(rrule is RRule.EveryXDays)+            val daily = rrule as RRule.EveryXDays+            assertEquals(2, daily.days); assertTrue(daily.endCondition is RRule.EndCondition.Never) },+        "weekly with byDay" to { val rrule = RRule.parse("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,FR", timeZone)+            assertNotNull(rrule); assertTrue(rrule is RRule.EveryXWeeks)+            val weekly = rrule as RRule.EveryXWeeks+            assertEquals(1, weekly.weeks); assertEquals(3, weekly.daysOfWeek.size)+            assertTrue(weekly.daysOfWeek.contains(DayOfWeek.MONDAY))+            assertTrue(weekly.daysOfWeek.contains(DayOfWeek.WEDNESDAY))+            assertTrue(weekly.daysOfWeek.contains(DayOfWeek.FRIDAY)) },+        "monthly with byMonthDay" to { val rrule = RRule.parse("FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=1,15,-1", timeZone)+            assertNotNull(rrule); assertTrue(rrule is RRule.EveryXMonths)+            val monthly = rrule as RRule.EveryXMonths+            assertNotNull(monthly.byMonthDay); assertEquals(3, monthly.byMonthDay!!.size)+            assertTrue(monthly.byMonthDay!!.contains(1))+            assertTrue(monthly.byMonthDay!!.contains(15))+            assertTrue(monthly.byMonthDay!!.contains(-1)) },+        "yearly with byMonth" to { val rrule = RRule.parse("FREQ=YEARLY;INTERVAL=1;BYMONTH=1,6,12", timeZone)+            assertNotNull(rrule); assertTrue(rrule is RRule.EveryXYears)+            val yearly = rrule as RRule.EveryXYears+            assertNotNull(yearly.byMonth); assertEquals(3, yearly.byMonth!!.size)+            assertTrue(yearly.byMonth!!.contains(1))+            assertTrue(yearly.byMonth!!.contains(6))+            assertTrue(yearly.byMonth!!.contains(12)) },+        "with bySetPos" to { val rrule = RRule.parse("FREQ=MONTHLY;INTERVAL=1;BYSETPOS=1,-1", timeZone)+            assertNotNull(rrule); assertTrue(rrule is RRule.EveryXMonths)+            val monthly = rrule as RRule.EveryXMonths+            assertNotNull(monthly.bySetPos); assertEquals(2, monthly.bySetPos!!.size)+            assertTrue(monthly.bySetPos!!.contains(1))+            assertTrue(monthly.bySetPos!!.contains(-1)) },+        "with byYearDay" to { val rrule = RRule.parse("FREQ=YEARLY;INTERVAL=1;BYYEARDAY=1,100,365", timeZone)+            assertNotNull(rrule); assertTrue(rrule is RRule.EveryXYears)+            val yearly = rrule as RRule.EveryXYears+            assertNotNull(yearly.byYearDay); assertEquals(3, yearly.byYearDay!!.size)+            assertTrue(yearly.byYearDay!!.contains(1))+            assertTrue(yearly.byYearDay!!.contains(100))+            assertTrue(yearly.byYearDay!!.contains(365)) },+        "with byWeekNo" to { val rrule = RRule.parse("FREQ=YEARLY;INTERVAL=1;BYWEEKNO=1,26,52", timeZone)+            assertNotNull(rrule); assertTrue(rrule is RRule.EveryXYears)+            val yearly = rrule as RRule.EveryXYears+            assertNotNull(yearly.byWeekNo); assertEquals(3, yearly.byWeekNo!!.size)+            assertTrue(yearly.byWeekNo!!.contains(1))+            assertTrue(yearly.byWeekNo!!.contains(26))+            assertTrue(yearly.byWeekNo!!.contains(52)) },+        "with wkst" to { val rrule = RRule.parse("FREQ=WEEKLY;INTERVAL=1;WKST=SU", timeZone)+            assertNotNull(rrule); assertTrue(rrule is RRule.EveryXWeeks)+            val weekly = rrule as RRule.EveryXWeeks+            assertNotNull(weekly.wkst); assertEquals(DayOfWeek.SUNDAY, weekly.wkst) },+        "with count" to { val rrule = RRule.parse("FREQ=DAILY;INTERVAL=1;COUNT=10", timeZone)+            assertNotNull(rrule); assertTrue(rrule is RRule.EveryXDays)+            val daily = rrule as RRule.EveryXDays+            assertTrue(daily.endCondition is RRule.EndCondition.Count)+            assertEquals(10L, (daily.endCondition as RRule.EndCondition.Count).count) },+        "with until" to { val rrule = RRule.parse("FREQ=DAILY;INTERVAL=1;UNTIL=20251231T235959Z", timeZone)+            assertNotNull(rrule); assertTrue(rrule is RRule.EveryXDays)+            val daily = rrule as RRule.EveryXDays+            assertTrue(daily.endCondition is RRule.EndCondition.Until)+            assertEquals(LocalDate(2025, 12, 31), (daily.endCondition as RRule.EndCondition.Until).date) },+        "complex monthly" to { val rrule = RRule.parse("FREQ=MONTHLY;INTERVAL=2;BYMONTHDAY=1,15;BYSETPOS=1,-1;COUNT=10", timeZone)+            assertNotNull(rrule); assertTrue(rrule is RRule.EveryXMonths)+            val monthly = rrule as RRule.EveryXMonths+            assertEquals(2, monthly.months)+            assertNotNull(monthly.byMonthDay); assertEquals(2, monthly.byMonthDay!!.size)+            assertNotNull(monthly.bySetPos); assertEquals(2, monthly.bySetPos!!.size)+            assertTrue(monthly.endCondition is RRule.EndCondition.Count) },+        "monthly nth weekday" to { val rrule = RRule.parse("FREQ=MONTHLY;INTERVAL=1;BYDAY=2TU", timeZone)+            assertTrue(rrule is RRule.EveryXMonths)+            assertEquals(1, (rrule as RRule.EveryXMonths).typeE) },+        "monthly last weekday" to { val rrule = RRule.parse("FREQ=MONTHLY;INTERVAL=1;BYDAY=-1MO", timeZone)+            assertTrue(rrule is RRule.EveryXMonths)+            assertEquals(2, (rrule as RRule.EveryXMonths).typeE) },+        "daily with byDay keeps weekday filter" to { val rrule = RRule.parse("FREQ=DAILY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR", timeZone)+            assertTrue(rrule is RRule.EveryXDays)+            val daily = rrule as RRule.EveryXDays+            assertEquals(+                listOf(DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY,+                    DayOfWeek.THURSDAY, DayOfWeek.FRIDAY),+                daily.byDay,+            ) },+    ))++    @Test+    fun asStringCases() = runRows(listOf(+        "daily with byMonthDay" to { val rrule = RRule.EveryXDays(+                days = 1, endCondition = RRule.EndCondition.Never, byMonthDay = listOf(1, 15, -1))+            val result = rrule.asString(LocalDate(2025, 1, 1), timeZone)+            assertTrue(result.contains("FREQ=DAILY")); assertTrue(result.contains("BYMONTHDAY=1,15,-1")) },+        "weekly with wkst" to { val rrule = RRule.EveryXWeeks(+                weeks = 1, daysOfWeek = listOf(DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY),+                endCondition = RRule.EndCondition.Never, wkst = DayOfWeek.SUNDAY)+            val result = rrule.asString(LocalDate(2025, 1, 1), timeZone)+            assertTrue(result.contains("FREQ=WEEKLY")); assertTrue(result.contains("BYDAY=MO,WE"))+            assertTrue(result.contains("WKST=SU")) },+        "monthly with multiple properties" to { val rrule = RRule.EveryXMonths(+                months = 2, typeE = 0, endCondition = RRule.EndCondition.Count(5),+                byMonthDay = listOf(1, 15), bySetPos = listOf(1, -1), byMonth = listOf(1, 6, 12))+            val result = rrule.asString(LocalDate(2025, 1, 1), timeZone)+            assertTrue(result.contains("FREQ=MONTHLY")); assertTrue(result.contains("INTERVAL=2"))+            assertTrue(result.contains("BYMONTHDAY=1,15")); assertTrue(result.contains("BYSETPOS=1,-1"))+            assertTrue(result.contains("BYMONTH=1,6,12")); assertTrue(result.contains("COUNT=5")) },+        "yearly with all properties" to { val rrule = RRule.EveryXYears(+                years = 1, endCondition = RRule.EndCondition.Never, byMonthDay = listOf(1),+                byMonth = listOf(1, 7), bySetPos = listOf(1), byYearDay = listOf(1, 365),+                byWeekNo = listOf(1, 52), wkst = DayOfWeek.MONDAY)+            val result = rrule.asString(LocalDate(2025, 1, 1), timeZone)+            assertTrue(result.contains("FREQ=YEARLY")); assertTrue(result.contains("BYMONTHDAY=1"))+            assertTrue(result.contains("BYMONTH=1,7")); assertTrue(result.contains("BYSETPOS=1"))+            assertTrue(result.contains("BYYEARDAY=1,365")); assertTrue(result.contains("BYWEEKNO=1,52"))+            assertTrue(result.contains("WKST=MO")) },+        "weekly round trip" to { val original = RRule.EveryXWeeks(+                weeks = 2, daysOfWeek = listOf(DayOfWeek.TUESDAY, DayOfWeek.THURSDAY),+                endCondition = RRule.EndCondition.Until(LocalDate(2025, 12, 31)),+                byMonthDay = listOf(1, 15), wkst = DayOfWeek.MONDAY)+            val parsed = RRule.parse(original.asString(LocalDate(2025, 1, 1), timeZone), timeZone)+            assertNotNull(parsed); assertTrue(parsed is RRule.EveryXWeeks)+            val weekly = parsed as RRule.EveryXWeeks+            assertEquals(2, weekly.weeks); assertEquals(2, weekly.daysOfWeek.size)+            assertNotNull(weekly.byMonthDay); assertEquals(2, weekly.byMonthDay!!.size)+            assertNotNull(weekly.wkst); assertEquals(DayOfWeek.MONDAY, weekly.wkst) },+    ))      @Test     fun testAsStringMonthlyLastWeekdayDerivesFromStartDate() {@@ -316,18 +217,6 @@ class RRuleTest {         assertTrue(derived.contains("BYDAY=2TU"), derived)     } -    @Test-    fun testParseDailyWithByDayKeepsWeekdayFilter() {-        val rrule = RRule.parse("FREQ=DAILY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR", timeZone)-        assertTrue(rrule is RRule.EveryXDays)-        val daily = rrule as RRule.EveryXDays-        assertEquals(-            listOf(DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY,-                DayOfWeek.THURSDAY, DayOfWeek.FRIDAY),-            daily.byDay,-        )-    }-     @Test     fun testDailyByDayRoundTripsUnchanged() {         // The "every weekday" shape emitted by other calendar apps: dropping BYDAY@@ -353,27 +242,4 @@ class RRuleTest {         assertTrue(parsed is RRule.EveryXMonths)         assertEquals(input, parsed.asString(LocalDate(2025, 1, 31), timeZone))     }--    @Test-    fun testRoundTripParsing() {-        val original = RRule.EveryXWeeks(-            weeks = 2,-            daysOfWeek = listOf(DayOfWeek.TUESDAY, DayOfWeek.THURSDAY),-            endCondition = RRule.EndCondition.Until(LocalDate(2025, 12, 31)),-            byMonthDay = listOf(1, 15),-            wkst = DayOfWeek.MONDAY-        )-        val firstDay = LocalDate(2025, 1, 1)-        val rruleStr = original.asString(firstDay, timeZone)-        val parsed = RRule.parse(rruleStr, timeZone)-        assertNotNull(parsed)-        assertTrue(parsed is RRule.EveryXWeeks)-        val weekly = parsed as RRule.EveryXWeeks-        assertEquals(2, weekly.weeks)-        assertEquals(2, weekly.daysOfWeek.size)-        assertNotNull(weekly.byMonthDay)-        assertEquals(2, weekly.byMonthDay!!.size)-        assertNotNull(weekly.wkst)-        assertEquals(DayOfWeek.MONDAY, weekly.wkst)-    } }
code/src/test/java/com/vayunmathur/code/util/EditorInputTest.kt
diff --git a/code/src/test/java/com/vayunmathur/code/util/EditorInputTest.kt b/code/src/test/java/com/vayunmathur/code/util/EditorInputTest.ktindex e027332648..acee8faadf 100644--- a/code/src/test/java/com/vayunmathur/code/util/EditorInputTest.kt+++ b/code/src/test/java/com/vayunmathur/code/util/EditorInputTest.kt@@ -4,6 +4,7 @@ import androidx.compose.ui.text.TextRange import androidx.compose.ui.text.input.TextFieldValue import kotlin.test.Test import kotlin.test.assertEquals+import kotlin.test.fail import com.vayunmathur.code.platform.applyEditorInput import com.vayunmathur.code.platform.deleteLine import com.vayunmathur.code.platform.duplicateLine@@ -30,95 +31,40 @@ class EditorInputTest {         autoCloseBrackets: Boolean = true,     ) = applyEditorInput(old, new, indentUnit, autoIndent, autoCloseBrackets) -    @Test-    fun newlineCarriesLeadingWhitespace() {-        val old = TextFieldValue("    foo", TextRange(7))-        val new = TextFieldValue("    foo\n", TextRange(8))-        val result = apply(old, new)-        assertEquals("    foo\n    ", result.text)-        assertEquals(12, result.selection.start)-    }--    @Test-    fun newlineBetweenBracketsOpensIndentedBlock() {-        val old = TextFieldValue("{}", TextRange(1))-        val new = TextFieldValue("{\n}", TextRange(2))-        val result = apply(old, new)-        assertEquals("{\n  \n}", result.text)-        assertEquals(4, result.selection.start)-    }--    @Test-    fun newlineBetweenBracketsCarriesExistingIndent() {-        val old = TextFieldValue("    {}", TextRange(5))-        val new = TextFieldValue("    {\n}", TextRange(6))-        val result = apply(old, new)-        assertEquals("    {\n      \n    }", result.text)-        assertEquals(12, result.selection.start)-    }--    @Test-    fun autoCloseInsertsMatchingBracket() {-        val old = TextFieldValue("", TextRange(0))-        val new = TextFieldValue("(", TextRange(1))-        val result = apply(old, new)-        assertEquals("()", result.text)-        assertEquals(1, result.selection.start)-    }--    @Test-    fun autoCloseInsertsMatchingQuote() {-        val old = TextFieldValue("", TextRange(0))-        val new = TextFieldValue("\"", TextRange(1))-        val result = apply(old, new)-        assertEquals("\"\"", result.text)-        assertEquals(1, result.selection.start)-    }--    @Test-    fun typingCloserOverExistingCloserTypesOver() {-        val old = TextFieldValue("()", TextRange(1))-        val new = TextFieldValue("())", TextRange(2))-        val result = apply(old, new)-        assertEquals("()", result.text)-        assertEquals(2, result.selection.start)-    }--    @Test-    fun autoCloseDisabledLeavesInsertionUntouched() {-        val old = TextFieldValue("", TextRange(0))-        val new = TextFieldValue("(", TextRange(1))-        val result = apply(old, new, autoCloseBrackets = false)-        assertEquals("(", result.text)-        assertEquals(1, result.selection.start)-    }--    @Test-    fun autoIndentDisabledLeavesNewlineUntouched() {-        val old = TextFieldValue("    foo", TextRange(7))-        val new = TextFieldValue("    foo\n", TextRange(8))-        val result = apply(old, new, autoIndent = false)-        assertEquals("    foo\n", result.text)-        assertEquals(8, result.selection.start)-    }--    @Test-    fun multiCharacterChangeIsReturnedUnchanged() {-        val old = TextFieldValue("", TextRange(0))-        val new = TextFieldValue("abc", TextRange(3))-        val result = apply(old, new)-        assertEquals("abc", result.text)-        assertEquals(3, result.selection.start)-    }--    @Test-    fun plainCharacterIsReturnedUnchanged() {-        val old = TextFieldValue("a", TextRange(1))-        val new = TextFieldValue("ab", TextRange(2))-        val result = apply(old, new)-        assertEquals("ab", result.text)-        assertEquals(2, result.selection.start)-    }+    /** Runs every row, then fails once with all failing row labels. */+    private fun runRows(rows: List<Pair<String, () -> Unit>>) {+        val failures = mutableListOf<String>()+        for ((label, check) in rows) {+            try { check() } catch (e: AssertionError) { failures += "$label: ${e.message}" }+        }+        if (failures.isNotEmpty()) fail(failures.joinToString("\n"))+    }++    @Test+    fun applyEditorInputCases() = runRows(listOf(+        "newline carries leading whitespace" to { val r = apply(TextFieldValue("    foo", TextRange(7)), TextFieldValue("    foo\n", TextRange(8)))+            assertEquals("    foo\n    ", r.text); assertEquals(12, r.selection.start) },+        "newline between brackets opens indented block" to { val r = apply(TextFieldValue("{}", TextRange(1)), TextFieldValue("{\n}", TextRange(2)))+            assertEquals("{\n  \n}", r.text); assertEquals(4, r.selection.start) },+        "newline between brackets carries existing indent" to { val r = apply(TextFieldValue("    {}", TextRange(5)), TextFieldValue("    {\n}", TextRange(6)))+            assertEquals("    {\n      \n    }", r.text); assertEquals(12, r.selection.start) },+        "auto-close inserts matching bracket" to { val r = apply(TextFieldValue("", TextRange(0)), TextFieldValue("(", TextRange(1)))+            assertEquals("()", r.text); assertEquals(1, r.selection.start) },+        "auto-close inserts matching quote" to { val r = apply(TextFieldValue("", TextRange(0)), TextFieldValue("\"", TextRange(1)))+            assertEquals("\"\"", r.text); assertEquals(1, r.selection.start) },+        "typing closer over existing closer types over" to { val r = apply(TextFieldValue("()", TextRange(1)), TextFieldValue("())", TextRange(2)))+            assertEquals("()", r.text); assertEquals(2, r.selection.start) },+        "auto-close disabled leaves insertion untouched" to { val r = apply(TextFieldValue("", TextRange(0)), TextFieldValue("(", TextRange(1)), autoCloseBrackets = false)+            assertEquals("(", r.text); assertEquals(1, r.selection.start) },+        "auto-indent disabled leaves newline untouched" to { val r = apply(TextFieldValue("    foo", TextRange(7)), TextFieldValue("    foo\n", TextRange(8)), autoIndent = false)+            assertEquals("    foo\n", r.text); assertEquals(8, r.selection.start) },+        "multi-character change is returned unchanged" to { val r = apply(TextFieldValue("", TextRange(0)), TextFieldValue("abc", TextRange(3)))+            assertEquals("abc", r.text); assertEquals(3, r.selection.start) },+        "plain character is returned unchanged" to { val r = apply(TextFieldValue("a", TextRange(1)), TextFieldValue("ab", TextRange(2)))+            assertEquals("ab", r.text); assertEquals(2, r.selection.start) },+        "newline with no indent splits line at caret" to { val r = apply(TextFieldValue("foobar", TextRange(3)), TextFieldValue("foo\nbar", TextRange(4)))+            assertEquals("foo\nbar", r.text); assertEquals(4, r.selection.start) },+    ))      @Test     fun editThatIsNotAPlainInsertionAtTheCaretIsReturnedUnchanged() {@@ -131,65 +77,49 @@ class EditorInputTest {     }      @Test-    fun lineStartOffsetFindsLineStarts() {-        val text = "a\nbb\nccc"-        assertEquals(0, lineStartOffset(text, 1))-        assertEquals(2, lineStartOffset(text, 2))-        assertEquals(5, lineStartOffset(text, 3))-    }--    @Test-    fun lineStartOffsetClampsOutOfRange() {-        val text = "a\nbb\nccc"-        assertEquals(text.length, lineStartOffset(text, 99))-        assertEquals(0, lineStartOffset(text, 0))-        assertEquals(0, lineStartOffset(text, -5))-    }--    @Test-    fun findLineMatchesLiteralIsCaseInsensitiveByDefault() {-        val text = "Foo\nbar\nfoobar"-        val matches = findLineMatches(text, "foo", caseSensitive = false, useRegex = false)-        assertEquals(listOf(1, 3), matches.map { it.line })-        assertEquals(listOf("Foo", "foobar"), matches.map { it.preview })-    }--    @Test-    fun findLineMatchesLiteralRespectsCaseSensitivity() {-        val text = "Foo\nfoo"-        val matches = findLineMatches(text, "foo", caseSensitive = true, useRegex = false)-        assertEquals(listOf(2), matches.map { it.line })-    }--    @Test-    fun findLineMatchesRegex() {-        val text = "foo\nbar\nfoobar"-        val matches = findLineMatches(text, "^foo", caseSensitive = true, useRegex = true)-        assertEquals(listOf(1, 3), matches.map { it.line })-    }+    fun lineStartOffsetCases() = runRows(listOf(+        "line 1 starts at 0" to { assertEquals(0, lineStartOffset("a\nbb\nccc", 1)) },+        "line 2 starts after first newline" to { assertEquals(2, lineStartOffset("a\nbb\nccc", 2)) },+        "line 3 starts after second newline" to { assertEquals(5, lineStartOffset("a\nbb\nccc", 3)) },+        "line past the end clamps to length" to { val text = "a\nbb\nccc"+            assertEquals(text.length, lineStartOffset(text, 99)) },+        "line 0 clamps to 0" to { assertEquals(0, lineStartOffset("a\nbb\nccc", 0)) },+        "negative line clamps to 0" to { assertEquals(0, lineStartOffset("a\nbb\nccc", -5)) },+    ))      @Test-    fun findLineMatchesRespectsLimit() {-        val text = "foo\nfoo\nfoo"-        val matches = findLineMatches(text, "foo", caseSensitive = false, useRegex = false, limit = 1)-        assertEquals(1, matches.size)-    }--    @Test-    fun findLineMatchesInvalidRegexYieldsNothing() {-        val text = "foo(bar"-        val matches = findLineMatches(text, "(", caseSensitive = false, useRegex = true)-        assertEquals(emptyList(), matches.map { it.line })-    }+    fun findLineMatchesCases() = runRows(listOf(+        "literal is case-insensitive by default" to { val m = findLineMatches("Foo\nbar\nfoobar", "foo", caseSensitive = false, useRegex = false)+            assertEquals(listOf(1, 3), m.map { it.line }); assertEquals(listOf("Foo", "foobar"), m.map { it.preview }) },+        "literal respects case sensitivity" to { val m = findLineMatches("Foo\nfoo", "foo", caseSensitive = true, useRegex = false)+            assertEquals(listOf(2), m.map { it.line }) },+        "regex match" to { val m = findLineMatches("foo\nbar\nfoobar", "^foo", caseSensitive = true, useRegex = true)+            assertEquals(listOf(1, 3), m.map { it.line }) },+        "respects limit" to { val m = findLineMatches("foo\nfoo\nfoo", "foo", caseSensitive = false, useRegex = false, limit = 1)+            assertEquals(1, m.size) },+        "invalid regex yields nothing" to { val m = findLineMatches("foo(bar", "(", caseSensitive = false, useRegex = true)+            assertEquals(emptyList(), m.map { it.line }) },+    ))      // ---- Line operations ----      @Test-    fun duplicateLineCopiesCurrentLineBelow() {-        val result = duplicateLine(TextFieldValue("foo\nbar", TextRange(1)))-        assertEquals("foo\nfoo\nbar", result.text)-        assertEquals(5, result.selection.start)-    }+    fun lineOperationCases() = runRows(listOf(+        "duplicate line copies current line below" to { val r = duplicateLine(TextFieldValue("foo\nbar", TextRange(1)))+            assertEquals("foo\nfoo\nbar", r.text); assertEquals(5, r.selection.start) },+        "delete line removes current line and newline" to { val r = deleteLine(TextFieldValue("foo\nbar\nbaz", TextRange(5)))+            assertEquals("foo\nbaz", r.text); assertEquals(4, r.selection.start) },+        "delete line on last line drops preceding newline" to { val r = deleteLine(TextFieldValue("foo\nbar", TextRange(6)))+            assertEquals("foo", r.text); assertEquals(3, r.selection.start) },+        "move line up swaps with line above" to { val r = moveLineUp(TextFieldValue("foo\nbar\nbaz", TextRange(5)))+            assertEquals("bar\nfoo\nbaz", r.text); assertEquals(1, r.selection.start) },+        "move line up on first line is no-op" to { val r = moveLineUp(TextFieldValue("foo\nbar", TextRange(1)))+            assertEquals("foo\nbar", r.text); assertEquals(1, r.selection.start) },+        "move line down swaps with line below" to { val r = moveLineDown(TextFieldValue("foo\nbar\nbaz", TextRange(1)))+            assertEquals("bar\nfoo\nbaz", r.text); assertEquals(5, r.selection.start) },+        "move line down on last line is no-op" to { val r = moveLineDown(TextFieldValue("foo\nbar", TextRange(5)))+            assertEquals("foo\nbar", r.text); assertEquals(5, r.selection.start) },+    ))      @Test     fun lineOpsIgnoreLineAtExclusiveSelectionEnd() {@@ -210,105 +140,30 @@ class EditorInputTest {         assertEquals("foo\nbar\nbar", duplicateLine(caret).text)     } -    @Test-    fun deleteLineRemovesCurrentLineAndNewline() {-        val result = deleteLine(TextFieldValue("foo\nbar\nbaz", TextRange(5)))-        assertEquals("foo\nbaz", result.text)-        assertEquals(4, result.selection.start)-    }--    @Test-    fun deleteLineOnLastLineDropsPrecedingNewline() {-        val result = deleteLine(TextFieldValue("foo\nbar", TextRange(6)))-        assertEquals("foo", result.text)-        assertEquals(3, result.selection.start)-    }--    @Test-    fun moveLineUpSwapsWithLineAbove() {-        val result = moveLineUp(TextFieldValue("foo\nbar\nbaz", TextRange(5)))-        assertEquals("bar\nfoo\nbaz", result.text)-        assertEquals(1, result.selection.start)-    }--    @Test-    fun moveLineUpOnFirstLineIsNoOp() {-        val value = TextFieldValue("foo\nbar", TextRange(1))-        val result = moveLineUp(value)-        assertEquals("foo\nbar", result.text)-        assertEquals(1, result.selection.start)-    }--    @Test-    fun moveLineDownSwapsWithLineBelow() {-        val result = moveLineDown(TextFieldValue("foo\nbar\nbaz", TextRange(1)))-        assertEquals("bar\nfoo\nbaz", result.text)-        assertEquals(5, result.selection.start)-    }--    @Test-    fun moveLineDownOnLastLineIsNoOp() {-        val value = TextFieldValue("foo\nbar", TextRange(5))-        val result = moveLineDown(value)-        assertEquals("foo\nbar", result.text)-        assertEquals(5, result.selection.start)-    }-     // ---- Comment toggle ----      @Test-    fun toggleCommentAddsPrefixWithSpace() {-        val result = toggleLineComment(TextFieldValue("foo", TextRange(0)), "//")-        assertEquals("// foo", result.text)-    }--    @Test-    fun toggleCommentRemovesPrefixAndSpace() {-        val result = toggleLineComment(TextFieldValue("// foo", TextRange(0)), "//")-        assertEquals("foo", result.text)-    }--    @Test-    fun toggleCommentPreservesIndent() {-        val result = toggleLineComment(TextFieldValue("    foo", TextRange(4)), "//")-        assertEquals("    // foo", result.text)-    }--    @Test-    fun toggleCommentAcrossMultipleLines() {-        val value = TextFieldValue("foo\nbar", TextRange(0, 7))-        val result = toggleLineComment(value, "#")-        assertEquals("# foo\n# bar", result.text)-    }--    @Test-    fun toggleCommentUncommentsWhenAllCommented() {-        val value = TextFieldValue("# foo\n# bar", TextRange(0, 11))-        val result = toggleLineComment(value, "#")-        assertEquals("foo\nbar", result.text)-    }--    @Test-    fun toggleCommentLeavesBlankLinesAlone() {-        val value = TextFieldValue("foo\n\nbar", TextRange(0, 8))-        val result = toggleLineComment(value, "//")-        assertEquals("// foo\n\n// bar", result.text)-    }+    fun toggleCommentCases() = runRows(listOf(+        "adds prefix with space" to { assertEquals("// foo", toggleLineComment(TextFieldValue("foo", TextRange(0)), "//").text) },+        "removes prefix and space" to { assertEquals("foo", toggleLineComment(TextFieldValue("// foo", TextRange(0)), "//").text) },+        "preserves indent" to { assertEquals("    // foo", toggleLineComment(TextFieldValue("    foo", TextRange(4)), "//").text) },+        "across multiple lines" to { assertEquals("# foo\n# bar", toggleLineComment(TextFieldValue("foo\nbar", TextRange(0, 7)), "#").text) },+        "uncomments when all commented" to { assertEquals("foo\nbar", toggleLineComment(TextFieldValue("# foo\n# bar", TextRange(0, 11)), "#").text) },+        "leaves blank lines alone" to { assertEquals("// foo\n\n// bar", toggleLineComment(TextFieldValue("foo\n\nbar", TextRange(0, 8)), "//").text) },+    ))      // ---- Paste re-indentation ----      @Test-    fun pasteReindentsBlockOntoCaretIndent() {+    fun pasteCases() = runRows(listOf(         // Caret sits after 4 spaces of indentation; the pasted block is de-dented then re-based.-        val result = reindentPaste("    ", 4, "if (x) {\n    y()\n}")-        assertEquals("    if (x) {\n        y()\n    }", result.text)-    }--    @Test-    fun pasteStripsCommonLeadingIndent() {-        val result = reindentPaste("", 0, "    a\n      b")-        assertEquals("a\n  b", result.text)-    }+        "reindents block onto caret indent" to { assertEquals("    if (x) {\n        y()\n    }", reindentPaste("    ", 4, "if (x) {\n    y()\n}").text) },+        "strips common leading indent" to { assertEquals("a\n  b", reindentPaste("", 0, "    a\n      b").text) },+        // Blank middle line keeps its own whitespace (only non-blank lines+        // re-base); later lines pick up the caret indent.+        "keeps blank lines blank" to { assertEquals("  a\n  \n    b", reindentPaste("  ", 2, "a\n\n  b").text) },+        "blank lines become empty" to { assertEquals("a\n\nb", reindentPaste("", 0, "a\n\nb").text) },+    ))      @Test     fun pasteThroughApplyEditorInputReindents() {@@ -319,14 +174,6 @@ class EditorInputTest {         assertEquals("    a\n        b", result.text)     } -    @Test-    fun pasteKeepsBlankLinesBlank() {-        val result = reindentPaste("  ", 2, "a\n\n  b")-        // Blank middle line keeps its own whitespace (only non-blank lines-        // re-base); later lines pick up the caret indent.-        assertEquals("  a\n  \n    b", result.text)-    }-     @Test     fun newlineWithNoIndentInsertsNewline() {         val old = TextFieldValue("foo", TextRange(3))@@ -338,41 +185,14 @@ class EditorInputTest {         assertEquals(4, result.selection.start)     } -    @Test-    fun newlineWithNoIndentSplitsLineAtCaret() {-        val old = TextFieldValue("foobar", TextRange(3))-        val new = TextFieldValue("foo\nbar", TextRange(4))-        val result = apply(old, new)-        assertEquals("foo\nbar", result.text)-        assertEquals(4, result.selection.start)-    }--    @Test-    fun pasteBlankLinesBecomeEmpty() {-        val result = reindentPaste("", 0, "a\n\nb")-        assertEquals("a\n\nb", result.text)-    }-     // ---- Save transforms ----      @Test-    fun trimTrailingWhitespaceRemovesLineEndSpaces() {-        assertEquals("a\nb", trimTrailingWhitespace("a  \nb\t"))-    }--    @Test-    fun trimTrailingWhitespaceKeepsInteriorAndNewlines() {-        assertEquals("a b\n\n", trimTrailingWhitespace("a b \n \n"))-    }--    @Test-    fun ensureFinalNewlineAddsWhenMissing() {-        assertEquals("a\n", ensureFinalNewline("a"))-    }--    @Test-    fun ensureFinalNewlineNoOpWhenPresentOrEmpty() {-        assertEquals("a\n", ensureFinalNewline("a\n"))-        assertEquals("", ensureFinalNewline(""))-    }+    fun saveTransformCases() = runRows(listOf(+        "trim removes line-end spaces" to { assertEquals("a\nb", trimTrailingWhitespace("a  \nb\t")) },+        "trim keeps interior and newlines" to { assertEquals("a b\n\n", trimTrailingWhitespace("a b \n \n")) },+        "ensure final newline adds when missing" to { assertEquals("a\n", ensureFinalNewline("a")) },+        "ensure final newline no-op when present" to { assertEquals("a\n", ensureFinalNewline("a\n")) },+        "ensure final newline no-op when empty" to { assertEquals("", ensureFinalNewline("")) },+    )) }