From 6312812b50a636fe9a1f3644d31c86897a54e09f Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 12:30:53 +0100 Subject: [PATCH 001/123] Remove unnecessary tuple element --- src/Test/Fuzz.elm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index 56b121e3..e28e8f9e 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -276,11 +276,11 @@ allSufficientlyCovered c state normalizedDistributionCount = |> Maybe.traverse (\( labels, count ) -> Dict.get labels expectedDistributions_ - |> Maybe.map (\expectedDistribution -> ( labels, count, expectedDistribution )) + |> Maybe.map (\expectedDistribution -> ( count, expectedDistribution )) ) |> Maybe.map (List.all - (\( _, count, expectedDistribution ) -> + (\( count, expectedDistribution ) -> case expectedDistribution of -- Zero and MoreThanZero will get checked in the Success case Zero -> From f593f2a8503b40d7862be688bd00f34b8717fcea Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 13:27:44 +0100 Subject: [PATCH 002/123] Convert to dictionary early --- src/Test/Distribution/Internal.elm | 20 ++++++++++++++++++-- src/Test/Fuzz.elm | 16 +++------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/Test/Distribution/Internal.elm b/src/Test/Distribution/Internal.elm index ad8dec98..c33eb48d 100644 --- a/src/Test/Distribution/Internal.elm +++ b/src/Test/Distribution/Internal.elm @@ -5,10 +5,13 @@ module Test.Distribution.Internal exposing , formatPct , getDistributionLabels , getExpectedDistributions + , getExpectedDistributionsAsList , insufficientlyCovered , sufficientlyCovered ) +import Dict exposing (Dict) + type Distribution a = NoDistributionNeeded @@ -48,8 +51,8 @@ getDistributionLabels distribution = Just (List.map (\( _, l, p ) -> ( l, p )) list) -getExpectedDistributions : Distribution a -> Maybe (List ( String, ExpectedDistribution )) -getExpectedDistributions distribution = +getExpectedDistributionsAsList : Distribution a -> Maybe (List ( String, ExpectedDistribution )) +getExpectedDistributionsAsList distribution = case distribution of NoDistributionNeeded -> Nothing @@ -61,6 +64,19 @@ getExpectedDistributions distribution = Just (List.map (\( e, l, _ ) -> ( l, e )) list) +getExpectedDistributions : Distribution a -> Maybe (Dict String ExpectedDistribution) +getExpectedDistributions distribution = + case distribution of + NoDistributionNeeded -> + Nothing + + ReportDistribution _ -> + Nothing + + ExpectDistribution list -> + Just (List.foldl (\( e, l, _ ) dict -> Dict.insert l e dict) Dict.empty list) + + formatPct : Float -> String formatPct n = let diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index e28e8f9e..f9d4dc96 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -256,11 +256,6 @@ allSufficientlyCovered c state normalizedDistributionCount = (Test.Distribution.Internal.getExpectedDistributions c.distribution) |> Maybe.andThen (\( distributionCount, expectedDistributions ) -> - let - expectedDistributions_ : Dict String ExpectedDistribution - expectedDistributions_ = - Dict.fromList expectedDistributions - in distributionCount -- Needs normalized distribution count: |> Dict.toList @@ -275,7 +270,7 @@ allSufficientlyCovered c state normalizedDistributionCount = ) |> Maybe.traverse (\( labels, count ) -> - Dict.get labels expectedDistributions_ + Dict.get labels expectedDistributions |> Maybe.map (\expectedDistribution -> ( count, expectedDistribution )) ) |> Maybe.map @@ -302,7 +297,7 @@ findBadZeroRelatedCase : LoopConstants a -> LoopState -> Maybe (Dict (List Strin findBadZeroRelatedCase c state normalizedDistributionCount = Maybe.map2 Tuple.pair normalizedDistributionCount - (Test.Distribution.Internal.getExpectedDistributions c.distribution) + (Test.Distribution.Internal.getExpectedDistributionsAsList c.distribution) |> Maybe.andThen (\( distributionCount, expectedDistributions ) -> expectedDistributions @@ -348,11 +343,6 @@ findInsufficientlyCoveredLabel c state normalizedDistributionCount = (Test.Distribution.Internal.getExpectedDistributions c.distribution) |> Maybe.andThen (\( distributionCount, expectedDistributions ) -> - let - expectedDistributions_ : Dict String ExpectedDistribution - expectedDistributions_ = - Dict.fromList expectedDistributions - in -- TODO loop ExpectedDistributions instead of looping the label combinations? distributionCount -- Needs normalized distribution count: @@ -361,7 +351,7 @@ findInsufficientlyCoveredLabel c state normalizedDistributionCount = (\( labels, count ) -> case labels of [ onlyLabel ] -> - Dict.get onlyLabel expectedDistributions_ + Dict.get onlyLabel expectedDistributions |> Maybe.map (\expectedDistribution -> ( onlyLabel, count, expectedDistribution )) _ -> From b12f8bbf0f23c7d33b19af7269eeff55d10f7bdc Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 13:28:54 +0100 Subject: [PATCH 003/123] Avoid tuple --- src/Test/Fuzz.elm | 74 +++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index f9d4dc96..c17fe9b5 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -295,45 +295,45 @@ allSufficientlyCovered c state normalizedDistributionCount = findBadZeroRelatedCase : LoopConstants a -> LoopState -> Maybe (Dict (List String) Int) -> Maybe DistributionFailure findBadZeroRelatedCase c state normalizedDistributionCount = - Maybe.map2 Tuple.pair + Maybe.map2 + (\distributionCount expectedDistributions -> + expectedDistributions + |> List.find + (\( label, expectedDistribution ) -> + case expectedDistribution of + Zero -> + -- TODO short-circuit Zero sooner: as soon as we increment its counter, during runNTimes. + Dict.get [ label ] distributionCount + -- TODO it would be better if we returned a bug failure here instead of failing with a dummy value + |> Maybe.withDefault 1 + |> (/=) 0 + + MoreThanZero -> + Dict.get [ label ] distributionCount + -- TODO it would be better if we returned a bug failure here instead of failing with a dummy value + |> Maybe.withDefault 0 + |> (==) 0 + + AtLeast _ -> + False + ) + |> Maybe.andThen + (\( label, expectedDistribution ) -> + Dict.get [ label ] distributionCount + |> Maybe.map + (\count -> + { label = label + , actualPercentage = toFloat count * 100 / toFloat state.runsElapsed + , expectedDistribution = expectedDistribution + , runsElapsed = state.runsElapsed + , distributionCount = distributionCount + } + ) + ) + ) normalizedDistributionCount (Test.Distribution.Internal.getExpectedDistributionsAsList c.distribution) - |> Maybe.andThen - (\( distributionCount, expectedDistributions ) -> - expectedDistributions - |> List.find - (\( label, expectedDistribution ) -> - case expectedDistribution of - Zero -> - -- TODO short-circuit Zero sooner: as soon as we increment its counter, during runNTimes. - Dict.get [ label ] distributionCount - -- TODO it would be better if we returned a bug failure here instead of failing with a dummy value - |> Maybe.withDefault 1 - |> (/=) 0 - - MoreThanZero -> - Dict.get [ label ] distributionCount - -- TODO it would be better if we returned a bug failure here instead of failing with a dummy value - |> Maybe.withDefault 0 - |> (==) 0 - - AtLeast _ -> - False - ) - |> Maybe.andThen - (\( label, expectedDistribution ) -> - Dict.get [ label ] distributionCount - |> Maybe.map - (\count -> - { label = label - , actualPercentage = toFloat count * 100 / toFloat state.runsElapsed - , expectedDistribution = expectedDistribution - , runsElapsed = state.runsElapsed - , distributionCount = distributionCount - } - ) - ) - ) + |> Maybe.andThen identity findInsufficientlyCoveredLabel : LoopConstants a -> LoopState -> Maybe (Dict (List String) Int) -> Maybe DistributionFailure From e51caa55ce19864ec219d9b9f8a1082152be2924 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 14:12:04 +0100 Subject: [PATCH 004/123] Use more lazy case expressions --- src/Test/Fuzz.elm | 78 +++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index c17fe9b5..c849a13a 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -295,45 +295,49 @@ allSufficientlyCovered c state normalizedDistributionCount = findBadZeroRelatedCase : LoopConstants a -> LoopState -> Maybe (Dict (List String) Int) -> Maybe DistributionFailure findBadZeroRelatedCase c state normalizedDistributionCount = - Maybe.map2 - (\distributionCount expectedDistributions -> - expectedDistributions - |> List.find - (\( label, expectedDistribution ) -> - case expectedDistribution of - Zero -> - -- TODO short-circuit Zero sooner: as soon as we increment its counter, during runNTimes. - Dict.get [ label ] distributionCount - -- TODO it would be better if we returned a bug failure here instead of failing with a dummy value - |> Maybe.withDefault 1 - |> (/=) 0 + case normalizedDistributionCount of + Nothing -> + Nothing - MoreThanZero -> - Dict.get [ label ] distributionCount - -- TODO it would be better if we returned a bug failure here instead of failing with a dummy value - |> Maybe.withDefault 0 - |> (==) 0 + Just distributionCount -> + case Test.Distribution.Internal.getExpectedDistributionsAsList c.distribution of + Nothing -> + Nothing - AtLeast _ -> - False - ) - |> Maybe.andThen - (\( label, expectedDistribution ) -> - Dict.get [ label ] distributionCount - |> Maybe.map - (\count -> - { label = label - , actualPercentage = toFloat count * 100 / toFloat state.runsElapsed - , expectedDistribution = expectedDistribution - , runsElapsed = state.runsElapsed - , distributionCount = distributionCount - } - ) - ) - ) - normalizedDistributionCount - (Test.Distribution.Internal.getExpectedDistributionsAsList c.distribution) - |> Maybe.andThen identity + Just expectedDistributions -> + expectedDistributions + |> List.find + (\( label, expectedDistribution ) -> + case expectedDistribution of + Zero -> + -- TODO short-circuit Zero sooner: as soon as we increment its counter, during runNTimes. + Dict.get [ label ] distributionCount + -- TODO it would be better if we returned a bug failure here instead of failing with a dummy value + |> Maybe.withDefault 1 + |> (/=) 0 + + MoreThanZero -> + Dict.get [ label ] distributionCount + -- TODO it would be better if we returned a bug failure here instead of failing with a dummy value + |> Maybe.withDefault 0 + |> (==) 0 + + AtLeast _ -> + False + ) + |> Maybe.andThen + (\( label, expectedDistribution ) -> + Dict.get [ label ] distributionCount + |> Maybe.map + (\count -> + { label = label + , actualPercentage = toFloat count * 100 / toFloat state.runsElapsed + , expectedDistribution = expectedDistribution + , runsElapsed = state.runsElapsed + , distributionCount = distributionCount + } + ) + ) findInsufficientlyCoveredLabel : LoopConstants a -> LoopState -> Maybe (Dict (List String) Int) -> Maybe DistributionFailure From 0ec3cd7889f082421f82ef322432c8ee671e7e5d Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 12:42:18 +0100 Subject: [PATCH 005/123] Apply simplifications --- src/Test/Html/Internal/ElmHtml/InternalTypes.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm index 35c80fe6..b9ced409 100644 --- a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm +++ b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm @@ -238,7 +238,7 @@ contextDecodeElmHtml context = decodeTextTag : Json.Decode.Decoder TextTagRecord decodeTextTag = field kernelConstants.virtualDom.text - (Json.Decode.andThen (\text -> Json.Decode.succeed { text = text }) Json.Decode.string) + (Json.Decode.map (\text -> { text = text }) Json.Decode.string) {-| decode a tagger From f947943e90efa3ee712bb3697686b8fe95be5065 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 12:43:14 +0100 Subject: [PATCH 006/123] Simplify --- src/Test/Html/Internal/ElmHtml/ToString.elm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/ToString.elm b/src/Test/Html/Internal/ElmHtml/ToString.elm index e9b85008..1c454d4c 100644 --- a/src/Test/Html/Internal/ElmHtml/ToString.elm +++ b/src/Test/Html/Internal/ElmHtml/ToString.elm @@ -152,6 +152,6 @@ nodeRecordToString options { tag, children, facts } = element kinds. -} _ -> - [ openTag [ classes, styles, stringAttributes, boolAttributes ] ] - ++ childrenStrings + openTag [ classes, styles, stringAttributes, boolAttributes ] + :: childrenStrings ++ [ closeTag ] From 31376376b8caff97b03f93bbf317d9857e54a18b Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 12:45:01 +0100 Subject: [PATCH 007/123] Simplify --- src/Test/Html/Internal/ElmHtml/ToString.elm | 3 +-- src/Test/Html/Selector/Internal.elm | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/ToString.elm b/src/Test/Html/Internal/ElmHtml/ToString.elm index 1c454d4c..d24c9d2f 100644 --- a/src/Test/Html/Internal/ElmHtml/ToString.elm +++ b/src/Test/Html/Internal/ElmHtml/ToString.elm @@ -99,8 +99,7 @@ nodeRecordToString options { tag, children, facts } = "" childrenStrings = - List.map (nodeToLines options) children - |> List.concat + List.concatMap (nodeToLines options) children |> List.map ((++) (String.repeat options.indent " ")) styles = diff --git a/src/Test/Html/Selector/Internal.elm b/src/Test/Html/Selector/Internal.elm index 3664c098..cf6c4f6e 100644 --- a/src/Test/Html/Selector/Internal.elm +++ b/src/Test/Html/Selector/Internal.elm @@ -25,12 +25,11 @@ selectorToString criteria = "\"" ++ s ++ "\"" boolToString b = - case b of - True -> - "True" + if b then + "True" - False -> - "False" + else + "False" in case criteria of All list -> From 6111af9dd862113b3613627774586013ec674225 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 12:45:15 +0100 Subject: [PATCH 008/123] Simplify --- src/MicroBitwiseExtra.elm | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/MicroBitwiseExtra.elm b/src/MicroBitwiseExtra.elm index 1b7c4dcf..512eeb30 100644 --- a/src/MicroBitwiseExtra.elm +++ b/src/MicroBitwiseExtra.elm @@ -28,17 +28,16 @@ isBitSet index num = int52FromTuple : ( Int, Int ) -> Int int52FromTuple ( highBits, lowBits ) = - (+) - (highBits - |> keepBits 20 - |> signedToUnsigned - -- Bitwise.shiftLeftBy 32 would be buggy, so we do: - |> (*) 0x0000000100000000 - ) - (lowBits + (highBits + |> keepBits 20 + |> signedToUnsigned + -- Bitwise.shiftLeftBy 32 would be buggy, so we do: + |> (*) 0x0000000100000000 + ) + + (lowBits |> signedToUnsigned |> keepBits 32 - ) + ) int52ToTuple : Int -> ( Int, Int ) From a722b83540763efdb521e1e91d8e7d2878c4f98b Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 12:45:29 +0100 Subject: [PATCH 009/123] Simplify --- src/Fuzz.elm | 6 +----- src/Simplify.elm | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index 4e806527..05b3ed67 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1670,11 +1670,7 @@ forcedChoice n = -} intToBool : Int -> Bool intToBool n = - if n == 0 then - False - - else - True + n /= 0 weightedBoolGenerator : Float -> Random.Generator Int diff --git a/src/Simplify.elm b/src/Simplify.elm index 6aefc27e..e88e57af 100644 --- a/src/Simplify.elm +++ b/src/Simplify.elm @@ -145,8 +145,7 @@ logState label state = let runString = Debug.toString (RandomRun.toList state.randomRun) - in - let + _ = case Fuzz.Internal.generate (PRNG.hardcoded state.randomRun) state.fuzzer of Generated { value } -> From 7bac4c54c4212c146f7036d6644612585b605d18 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 12:46:20 +0100 Subject: [PATCH 010/123] Simplify --- tests/src/Runner/String.elm | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/src/Runner/String.elm b/tests/src/Runner/String.elm index 1cd4920a..9ad088a7 100644 --- a/tests/src/Runner/String.elm +++ b/tests/src/Runner/String.elm @@ -118,7 +118,6 @@ fromExpectation labels expectation summary = { summaryWithDistribution | output = summaryWithDistribution.output ++ newOutput , failed = summaryWithDistribution.failed + 1 - , passed = summaryWithDistribution.passed } From ace318e15db9c6343ec06faa440fd504686f7af0 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 12:48:44 +0100 Subject: [PATCH 011/123] Simplify --- tests/src/FuzzerTests.elm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/src/FuzzerTests.elm b/tests/src/FuzzerTests.elm index d2a9ace0..5d6b0484 100644 --- a/tests/src/FuzzerTests.elm +++ b/tests/src/FuzzerTests.elm @@ -167,7 +167,7 @@ fuzzerSpecificationTests = (\v -> v == 999) , passes "Returns what you give it - Bool" (Fuzz.constant True) - (\v -> v == True) + (\v -> v) , simplifiesTowards "42" 42 (Fuzz.constant 42) fullySimplify ] , describe "maybe" @@ -525,7 +525,7 @@ fuzzerSpecificationTests = (Fuzz.list Fuzz.unit) (not << List.isEmpty) , simplifiesTowards "simplest" [] (Fuzz.list Fuzz.int) fullySimplify - , simplifiesTowardsWith { runs = 2000 } "next simplest" [ 0 ] (Fuzz.list Fuzz.int) (\x -> x == []) + , simplifiesTowardsWith { runs = 2000 } "next simplest" [ 0 ] (Fuzz.list Fuzz.int) List.isEmpty , simplifiesTowardsMany "All lists are sorted" [ [ 0, -1 ] , [ 1, 0 ] @@ -889,7 +889,7 @@ fuzzerSpecificationTests = (Fuzz.constant ((+) 1) |> Fuzz.andMap (Fuzz.constant n) ) - (Fuzz.constant ((+) 1 n)) + (Fuzz.constant (1 + n)) ) ) (\( left, right ) -> left == right) @@ -996,16 +996,16 @@ fuzzerSpecificationTests = , canGenerate True (Fuzz.weightedBool 0.5) , passes "0 = always False" (Fuzz.weightedBool 0) - (\bool -> bool == False) + (\bool -> not bool) , passes "1 = always True" (Fuzz.weightedBool 1) - (\bool -> bool == True) + (\bool -> bool) , passes "<0 clamps to 0" (Fuzz.weightedBool -0.5) - (\bool -> bool == False) + (\bool -> not bool) , passes ">1 clamps to 1" (Fuzz.weightedBool 1.5) - (\bool -> bool == True) + (\bool -> bool) , simplifiesTowards "simplest" False (Fuzz.weightedBool 0.5) fullySimplify , simplifiesTowards "non-False" True (Fuzz.weightedBool 0.5) (\x -> x == False) ] From 77c6f96a1828f10445dfd9951e2646c3408680db Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 12:55:56 +0100 Subject: [PATCH 012/123] Remove unused variables --- src/Fuzz.elm | 1 - src/Test/Fuzz.elm | 1 - src/Test/Html/Internal/ElmHtml/Query.elm | 1 - src/Test/Html/Internal/ElmHtml/ToString.elm | 1 - src/Test/Runner.elm | 2 -- tests/src/FuzzerTests.elm | 2 +- tests/src/Main.elm | 1 - tests/src/Runner/Log.elm | 1 - tests/src/Runner/String.elm | 6 ------ tests/src/Runner/String/Distribution.elm | 4 ---- tests/src/ShrinkingChallengeTests.elm | 1 - 11 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index 05b3ed67..0c137d88 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -75,7 +75,6 @@ can usually find the simplest input that reproduces a bug. import Array exposing (Array) import Bitwise -import Char import Dict exposing (Dict) import Fuzz.Float import Fuzz.Internal exposing (Fuzzer(..)) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index c849a13a..dad9f5ce 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -14,7 +14,6 @@ import Test.Distribution exposing (DistributionReport(..)) import Test.Distribution.Internal exposing (Distribution(..), ExpectedDistribution(..)) import Test.Expectation exposing (Expectation(..)) import Test.Internal exposing (Test(..), blankDescriptionFailure) -import Test.Runner.Distribution import Test.Runner.Failure exposing (InvalidReason(..), Reason(..)) diff --git a/src/Test/Html/Internal/ElmHtml/Query.elm b/src/Test/Html/Internal/ElmHtml/Query.elm index a1d519c4..2f31ada8 100644 --- a/src/Test/Html/Internal/ElmHtml/Query.elm +++ b/src/Test/Html/Internal/ElmHtml/Query.elm @@ -15,7 +15,6 @@ module Test.Html.Internal.ElmHtml.Query exposing -} import Dict -import String import Test.Html.Internal.ElmHtml.InternalTypes exposing (..) diff --git a/src/Test/Html/Internal/ElmHtml/ToString.elm b/src/Test/Html/Internal/ElmHtml/ToString.elm index d24c9d2f..f2e3e5d5 100644 --- a/src/Test/Html/Internal/ElmHtml/ToString.elm +++ b/src/Test/Html/Internal/ElmHtml/ToString.elm @@ -12,7 +12,6 @@ module Test.Html.Internal.ElmHtml.ToString exposing -} import Dict -import String import Test.Html.Internal.ElmHtml.InternalTypes exposing (..) diff --git a/src/Test/Runner.elm b/src/Test/Runner.elm index 5170de4a..3f6fb50e 100644 --- a/src/Test/Runner.elm +++ b/src/Test/Runner.elm @@ -41,7 +41,6 @@ These functions give you the ability to run fuzzers separate of running fuzz tes -} import Bitwise -import Char import Elm.Kernel.Test import Expect exposing (Expectation) import Fuzz exposing (Fuzzer) @@ -51,7 +50,6 @@ import PRNG import Random import RandomRun exposing (RandomRun) import Simplify -import String import Test exposing (Test) import Test.Distribution exposing (DistributionReport) import Test.Expectation diff --git a/tests/src/FuzzerTests.elm b/tests/src/FuzzerTests.elm index 5d6b0484..1dfeea4a 100644 --- a/tests/src/FuzzerTests.elm +++ b/tests/src/FuzzerTests.elm @@ -4,7 +4,7 @@ import Array import Expect exposing (Expectation) import Fuzz exposing (..) import Helpers exposing (..) -import Random exposing (Generator) +import Random import Test exposing (..) import Test.Distribution import Test.Runner exposing (Simplifiable) diff --git a/tests/src/Main.elm b/tests/src/Main.elm index 1cc3d9d4..7898d0e8 100644 --- a/tests/src/Main.elm +++ b/tests/src/Main.elm @@ -8,7 +8,6 @@ Note that this always uses an initial seed of 902101337, since it can't do effec -} -import Platform import Runner.Log import Runner.String exposing (Summary) import SeedTests diff --git a/tests/src/Runner/Log.elm b/tests/src/Runner/Log.elm index 2aa005e7..cfe3338b 100644 --- a/tests/src/Runner/Log.elm +++ b/tests/src/Runner/Log.elm @@ -23,7 +23,6 @@ if the tests all passed, and 1 if any failed. import Random import Runner.String exposing (Summary) -import String import Test exposing (Test) diff --git a/tests/src/Runner/String.elm b/tests/src/Runner/String.elm index 9ad088a7..0e7d7507 100644 --- a/tests/src/Runner/String.elm +++ b/tests/src/Runner/String.elm @@ -11,7 +11,6 @@ Note that this always uses an initial seed of 902101337, since it can't do effec -} -import Dict exposing (Dict) import Expect exposing (Expectation) import Random import Runner.String.Distribution @@ -138,11 +137,6 @@ defaultRuns = 100 -wrap : String -> String -> String -wrap delimiter string = - delimiter ++ string ++ delimiter - - indentLines : String -> String indentLines str = str diff --git a/tests/src/Runner/String/Distribution.elm b/tests/src/Runner/String/Distribution.elm index e6fa466b..fdf9b4d5 100644 --- a/tests/src/Runner/String/Distribution.elm +++ b/tests/src/Runner/String/Distribution.elm @@ -1,10 +1,6 @@ module Runner.String.Distribution exposing (report) -import Dict exposing (Dict) -import Expect exposing (Expectation) -import Set exposing (Set) import Test.Distribution exposing (DistributionReport(..)) -import Test.Runner report : List String -> DistributionReport -> Maybe String diff --git a/tests/src/ShrinkingChallengeTests.elm b/tests/src/ShrinkingChallengeTests.elm index 813f58d0..26ac47b6 100644 --- a/tests/src/ShrinkingChallengeTests.elm +++ b/tests/src/ShrinkingChallengeTests.elm @@ -2,7 +2,6 @@ module ShrinkingChallengeTests exposing (shrinkingChallenges) import Fuzz exposing (..) import Helpers exposing (..) -import Random import Set import Test exposing (..) From 36ed8be4bec00aa81878f7a10fe7e55103ce4232 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 12:57:15 +0100 Subject: [PATCH 013/123] Remove unused parameters --- src/Simplify/Cmd.elm | 6 +++--- tests/src/FuzzerTests.elm | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index df8a8977..6a99df99 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -90,7 +90,7 @@ cmdsForRun run = List.fastConcat [ deletionCmds length , zeroCmds length - , minimizeChoiceCmds run length + , minimizeChoiceCmds run , minimizeFloatCmds run length , sortCmds length , redistributeCmds length @@ -126,8 +126,8 @@ sortCmds length = } -minimizeChoiceCmds : RandomRun -> Int -> List SimplifyCmd -minimizeChoiceCmds run length = +minimizeChoiceCmds : RandomRun -> List SimplifyCmd +minimizeChoiceCmds run = run |> RandomRun.toList |> List.indexedMap Tuple.pair diff --git a/tests/src/FuzzerTests.elm b/tests/src/FuzzerTests.elm index 1dfeea4a..c5a8919a 100644 --- a/tests/src/FuzzerTests.elm +++ b/tests/src/FuzzerTests.elm @@ -1182,7 +1182,7 @@ distributionTests = } (Fuzz.intRange 1 20) "Int range boundaries" - (\n -> Expect.pass) + (\_ -> Expect.pass) , Test.fuzzWith { runs = 10000 , distribution = @@ -1193,7 +1193,7 @@ distributionTests = } (Fuzz.intRange 1 20) "Fizz buzz" - (\n -> Expect.pass) + (\_ -> Expect.pass) , Test.fuzzWith { runs = 10000 , distribution = @@ -1206,7 +1206,7 @@ distributionTests = } (Fuzz.intRange 1 20) "Fizz buzz even odd" - (\n -> Expect.pass) + (\_ -> Expect.pass) , Test.fuzzWith { runs = 10000 , distribution = @@ -1220,7 +1220,7 @@ distributionTests = } (Fuzz.intRange 1 20) "Int range boundaries - mandatory" - (\n -> Expect.pass) + (\_ -> Expect.pass) ] From 4d051f91d3836c1d17d3495d2c2e8bf8ac4abb0e Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 12:57:22 +0100 Subject: [PATCH 014/123] Remove unused parameter --- tests/src/Test/Html/ExampleApp.elm | 4 ++-- tests/src/Test/Html/ExampleAppTests.elm | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/src/Test/Html/ExampleApp.elm b/tests/src/Test/Html/ExampleApp.elm index 2e7a3eca..c1e64d0f 100644 --- a/tests/src/Test/Html/ExampleApp.elm +++ b/tests/src/Test/Html/ExampleApp.elm @@ -21,8 +21,8 @@ type Msg | GoToExamples -view : Model -> Html Msg -view _ = +view : Html Msg +view = div [ class "container" ] [ header [ class "funky themed", id "heading" ] [ a [ href "http://elm-lang.org", onClick GoToHome ] [ text "home" ] diff --git a/tests/src/Test/Html/ExampleAppTests.elm b/tests/src/Test/Html/ExampleAppTests.elm index 1e781081..8dd0533b 100644 --- a/tests/src/Test/Html/ExampleAppTests.elm +++ b/tests/src/Test/Html/ExampleAppTests.elm @@ -12,7 +12,7 @@ all : Test all = let output = - view exampleModel + view |> Query.fromHtml in describe "view exampleModel" From 0c6090653d50c55d85edf14fe244938a0cd889a4 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 13:00:04 +0100 Subject: [PATCH 015/123] Remove unused exports --- src/Test/Html/Internal/ElmHtml/InternalTypes.elm | 4 ++-- src/Test/Html/Internal/ElmHtml/Markdown.elm | 4 ++-- src/Test/Html/Internal/ElmHtml/Query.elm | 6 ++---- src/Test/Html/Internal/ElmHtml/ToString.elm | 8 ++++---- src/Test/Html/Query/Internal.elm | 2 +- src/Test/Html/Selector/Internal.elm | 2 +- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm index b9ced409..5ef865a4 100644 --- a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm +++ b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm @@ -3,7 +3,7 @@ module Test.Html.Internal.ElmHtml.InternalTypes exposing , Facts, Tagger, EventHandler, ElementKind(..) , Attribute(..), AttributeRecord, NamespacedAttributeRecord, PropertyRecord, EventRecord , Validation(..), validationMessage, validationFromMessage - , decodeElmHtml, emptyFacts, toElementKind, decodeAttribute + , decodeElmHtml, toElementKind, decodeAttribute ) {-| Internal types used to represent Elm Html in pure Elm @@ -16,7 +16,7 @@ module Test.Html.Internal.ElmHtml.InternalTypes exposing @docs Validation, validationMessage, validationFromMessage -@docs decodeElmHtml, emptyFacts, toElementKind, decodeAttribute +@docs decodeElmHtml, toElementKind, decodeAttribute -} diff --git a/src/Test/Html/Internal/ElmHtml/Markdown.elm b/src/Test/Html/Internal/ElmHtml/Markdown.elm index cdbef7af..5dde8563 100644 --- a/src/Test/Html/Internal/ElmHtml/Markdown.elm +++ b/src/Test/Html/Internal/ElmHtml/Markdown.elm @@ -1,11 +1,11 @@ module Test.Html.Internal.ElmHtml.Markdown exposing - ( MarkdownOptions, MarkdownModel, baseMarkdownModel + ( MarkdownOptions, MarkdownModel , decodeMarkdownModel ) {-| Markdown helpers -@docs MarkdownOptions, MarkdownModel, baseMarkdownModel +@docs MarkdownOptions, MarkdownModel @docs decodeMarkdownModel diff --git a/src/Test/Html/Internal/ElmHtml/Query.elm b/src/Test/Html/Internal/ElmHtml/Query.elm index 2f31ada8..3844ecbe 100644 --- a/src/Test/Html/Internal/ElmHtml/Query.elm +++ b/src/Test/Html/Internal/ElmHtml/Query.elm @@ -1,15 +1,13 @@ module Test.Html.Internal.ElmHtml.Query exposing ( Selector(..) - , query, queryAll, queryChildren, queryChildrenAll, queryInNode - , queryById, queryByClassName, queryByClassList, queryByStyle, queryByTagName, queryByAttribute, queryByBoolAttribute + , query, queryChildren , getChildren ) {-| Query things using ElmHtml @docs Selector -@docs query, queryAll, queryChildren, queryChildrenAll, queryInNode -@docs queryById, queryByClassName, queryByClassList, queryByStyle, queryByTagName, queryByAttribute, queryByBoolAttribute +@docs query, queryChildren @docs getChildren -} diff --git a/src/Test/Html/Internal/ElmHtml/ToString.elm b/src/Test/Html/Internal/ElmHtml/ToString.elm index f2e3e5d5..a92496b3 100644 --- a/src/Test/Html/Internal/ElmHtml/ToString.elm +++ b/src/Test/Html/Internal/ElmHtml/ToString.elm @@ -1,13 +1,13 @@ module Test.Html.Internal.ElmHtml.ToString exposing - ( nodeRecordToString, nodeToString, nodeToStringWithOptions - , FormatOptions, defaultFormatOptions + ( nodeToStringWithOptions + , FormatOptions ) {-| Convert ElmHtml to string. -@docs nodeRecordToString, nodeToString, nodeToStringWithOptions +@docs nodeToStringWithOptions -@docs FormatOptions, defaultFormatOptions +@docs FormatOptions -} diff --git a/src/Test/Html/Query/Internal.elm b/src/Test/Html/Query/Internal.elm index 0cacd3d3..2aaaf2b4 100644 --- a/src/Test/Html/Query/Internal.elm +++ b/src/Test/Html/Query/Internal.elm @@ -1,4 +1,4 @@ -module Test.Html.Query.Internal exposing (Multiple(..), Query(..), QueryError(..), SelectorQuery(..), Single(..), addQueryFromHtmlLine, baseIndentation, contains, expectAll, expectAllHelp, failWithQuery, getChildren, getElementAt, getElementAtHelp, getHtmlContext, has, hasNot, isElement, joinAsList, missingDescendants, multipleToExpectation, prefixOutputLine, prependSelector, prettyPrint, printIndented, queryErrorToString, showSelectorOutcome, showSelectorOutcomeInverse, toLines, toLinesHelp, toOutputLine, traverse, traverseSelector, traverseSelectors, verifySingle, withHtmlContext) +module Test.Html.Query.Internal exposing (Multiple(..), Query(..), QueryError, SelectorQuery(..), Single(..), contains, expectAll, failWithQuery, has, hasNot, joinAsList, multipleToExpectation, prependSelector, prettyPrint, queryErrorToString, traverse, verifySingle) import Expect exposing (Expectation) import Test.Html.Descendant as Descendant diff --git a/src/Test/Html/Selector/Internal.elm b/src/Test/Html/Selector/Internal.elm index cf6c4f6e..d0e6b541 100644 --- a/src/Test/Html/Selector/Internal.elm +++ b/src/Test/Html/Selector/Internal.elm @@ -1,4 +1,4 @@ -module Test.Html.Selector.Internal exposing (Selector(..), hasAll, namedAttr, namedBoolAttr, query, queryAll, queryAllChildren, selectorToString, styleToString) +module Test.Html.Selector.Internal exposing (Selector(..), hasAll, namedAttr, namedBoolAttr, queryAll, queryAllChildren, selectorToString) import Test.Html.Internal.ElmHtml.InternalTypes exposing (ElmHtml) import Test.Html.Internal.ElmHtml.Query as ElmHtmlQuery From 1492319b1d51448df0a9a1187f03479ecc643de4 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Fri, 13 Feb 2026 22:06:55 +0100 Subject: [PATCH 016/123] Remove unused declaration --- src/Test/Html/Internal/ElmHtml/InternalTypes.elm | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm index 5ef865a4..6c5f9385 100644 --- a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm +++ b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm @@ -421,18 +421,6 @@ decodeFacts (HtmlContext taggers eventDecoder) = (decodeOthers Json.Decode.bool Nothing) -{-| Just empty facts --} -emptyFacts : Facts msg -emptyFacts = - { styles = Dict.empty - , events = Dict.empty - , attributeNamespace = Nothing - , stringAttributes = Dict.empty - , boolAttributes = Dict.empty - } - - {-| Decode a JSON object into an Attribute. You have to pass a function that decodes events from event attributes. If you don't want to decode event msgs, you can ignore it: From ca250acc3be927edf508416d02a0a078cb96a88d Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 13:01:36 +0100 Subject: [PATCH 017/123] Remove unused custom type constructors --- src/Test/Html/Internal/ElmHtml/InternalTypes.elm | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm index 6c5f9385..e54dfa3d 100644 --- a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm +++ b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm @@ -122,7 +122,6 @@ type ElementKind = VoidElements | RawTextElements | EscapableRawTextElements - | ForeignElements | NormalElements @@ -148,7 +147,6 @@ type Attribute | NamespacedAttribute NamespacedAttributeRecord | Property PropertyRecord | Style { key : String, value : String } - | Event EventRecord {-| Attribute contains a string key and a string value From ccdddee3a93c0d09d1a0c3e42e1e4b5747bc1171 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 13:03:42 +0100 Subject: [PATCH 018/123] Make pattern explicit --- src/Test/Html/Selector.elm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Test/Html/Selector.elm b/src/Test/Html/Selector.elm index 4d22d522..a61505e5 100644 --- a/src/Test/Html/Selector.elm +++ b/src/Test/Html/Selector.elm @@ -219,7 +219,10 @@ attribute attr = Ok (InternalTypes.Style { key, value }) -> Style { key = key, value = value } - _ -> + Ok (InternalTypes.NamespacedAttribute _) -> + Invalid + + Err _ -> Invalid From 7ad1ad9639ebb0a8342e2931d3247a54d7f363f9 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 13:21:53 +0100 Subject: [PATCH 019/123] Apply NoPrematureLetComputation --- src/Expect.elm | 15 ++++++++------- src/RandomRun.elm | 8 ++++---- src/Simplify.elm | 6 +++--- src/Test/Html/Internal/ElmHtml/ToString.elm | 15 ++++++++------- src/Test/Html/Query/Internal.elm | 18 +++++++++--------- 5 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/Expect.elm b/src/Expect.elm index 3d597b43..dc34ae15 100644 --- a/src/Expect.elm +++ b/src/Expect.elm @@ -731,15 +731,16 @@ equateWith reason comparison b a = usesFloats = isFloat (Internal.toString a) || isFloat (Internal.toString b) - - floatError = - if String.contains reason "not" then - "Do not use Expect.notEqual with floats. Use Expect.notWithin instead." - - else - "Do not use Expect.equal with floats. Use Expect.within instead." in if usesFloats then + let + floatError = + if String.contains reason "not" then + "Do not use Expect.notEqual with floats. Use Expect.notWithin instead." + + else + "Do not use Expect.equal with floats. Use Expect.within instead." + in fail floatError else diff --git a/src/RandomRun.elm b/src/RandomRun.elm index dca1c4dc..1c4d4863 100644 --- a/src/RandomRun.elm +++ b/src/RandomRun.elm @@ -190,12 +190,12 @@ swapChunks : -> RandomRun -> Maybe RandomRun swapChunks { leftChunk, rightChunk } run = - let - list = - Queue.toList run.data - in Maybe.map2 (\lefts rights -> + let + list = + Queue.toList run.data + in replaceInList (List.concat [ List.indexedMap (\i n -> ( rightChunk.startIndex + i, n )) lefts diff --git a/src/Simplify.elm b/src/Simplify.elm index e88e57af..e5f83de3 100644 --- a/src/Simplify.elm +++ b/src/Simplify.elm @@ -143,13 +143,13 @@ logRun label run = logState : String -> State a -> State a logState label state = let - runString = - Debug.toString (RandomRun.toList state.randomRun) - _ = case Fuzz.Internal.generate (PRNG.hardcoded state.randomRun) state.fuzzer of Generated { value } -> let + runString = + Debug.toString (RandomRun.toList state.randomRun) + _ = Debug.log (label ++ " - " ++ runString ++ " --->") value in diff --git a/src/Test/Html/Internal/ElmHtml/ToString.elm b/src/Test/Html/Internal/ElmHtml/ToString.elm index a92496b3..4f0af21a 100644 --- a/src/Test/Html/Internal/ElmHtml/ToString.elm +++ b/src/Test/Html/Internal/ElmHtml/ToString.elm @@ -94,13 +94,6 @@ nodeRecordToString options { tag, children, facts } = in "<" ++ tag ++ filling ++ ">" - closeTag = - "" - - childrenStrings = - List.concatMap (nodeToLines options) children - |> List.map ((++) (String.repeat options.indent " ")) - styles = case Dict.toList facts.styles of [] -> @@ -150,6 +143,14 @@ nodeRecordToString options { tag, children, facts } = element kinds. -} _ -> + let + closeTag = + "" + + childrenStrings = + List.concatMap (nodeToLines options) children + |> List.map ((++) (String.repeat options.indent " ")) + in openTag [ classes, styles, stringAttributes, boolAttributes ] :: childrenStrings ++ [ closeTag ] diff --git a/src/Test/Html/Query/Internal.elm b/src/Test/Html/Query/Internal.elm index 2aaaf2b4..96006123 100644 --- a/src/Test/Html/Query/Internal.elm +++ b/src/Test/Html/Query/Internal.elm @@ -228,20 +228,20 @@ joinAsList toStr list = printIndented : Int -> Int -> ElmHtml msg -> String printIndented maxDigits index elmHtml = - let - caption = - (String.fromInt (index + 1) ++ ")") - |> String.padRight (maxDigits + 3) ' ' - |> String.append baseIndentation - - indentation = - String.repeat (String.length caption) " " - in case String.split "\n" (prettyPrint elmHtml) of [] -> "" first :: rest -> + let + caption = + (String.fromInt (index + 1) ++ ")") + |> String.padRight (maxDigits + 3) ' ' + |> String.append baseIndentation + + indentation = + String.repeat (String.length caption) " " + in rest |> List.map (String.append indentation) |> (::) (caption ++ first) From 5ce3296c8bac49afa8db2bbd4d56db2dfca976bb Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 13:23:14 +0100 Subject: [PATCH 020/123] Apply NoSimpleLetBody --- src/RandomRun.elm | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/RandomRun.elm b/src/RandomRun.elm index 1c4d4863..32ac723b 100644 --- a/src/RandomRun.elm +++ b/src/RandomRun.elm @@ -103,18 +103,15 @@ deleteChunk chunk run = let list = Queue.toList run.data - - result = - { run - | length = run.length - chunk.size - , data = - (List.take chunk.startIndex list - ++ List.drop (chunk.startIndex + chunk.size) list - ) - |> Queue.fromList - } in - result + { run + | length = run.length - chunk.size + , data = + (List.take chunk.startIndex list + ++ List.drop (chunk.startIndex + chunk.size) list + ) + |> Queue.fromList + } else run From da28b4b5a32f6837aa0d51f4395f3f8a6784b7c4 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 14:13:10 +0100 Subject: [PATCH 021/123] Remove unused field --- src/Test/Fuzz.elm | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index dad9f5ce..fb43a476 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -244,7 +244,6 @@ type alias DistributionFailure = , actualPercentage : Float , expectedDistribution : ExpectedDistribution , runsElapsed : Int - , distributionCount : Dict (List String) Int } @@ -333,7 +332,6 @@ findBadZeroRelatedCase c state normalizedDistributionCount = , actualPercentage = toFloat count * 100 / toFloat state.runsElapsed , expectedDistribution = expectedDistribution , runsElapsed = state.runsElapsed - , distributionCount = distributionCount } ) ) @@ -378,7 +376,6 @@ findInsufficientlyCoveredLabel c state normalizedDistributionCount = , actualPercentage = toFloat count * 100 / toFloat state.runsElapsed , expectedDistribution = expectedDistribution , runsElapsed = state.runsElapsed - , distributionCount = distributionCount } ) ) From 341947158ce824e0572d7c12010d3bb3cdb21f00 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 14:21:20 +0100 Subject: [PATCH 022/123] Pattern match earlier --- src/Test/Fuzz.elm | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index fb43a476..f2f794a7 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -352,24 +352,27 @@ findInsufficientlyCoveredLabel c state normalizedDistributionCount = (\( labels, count ) -> case labels of [ onlyLabel ] -> - Dict.get onlyLabel expectedDistributions - |> Maybe.map (\expectedDistribution -> ( onlyLabel, count, expectedDistribution )) + case Dict.get onlyLabel expectedDistributions of + Just Zero -> + Nothing - _ -> - Nothing - ) - |> List.find - (\( _, count, expectedDistribution ) -> - case expectedDistribution of - Zero -> - False + Just MoreThanZero -> + Nothing + + Just ((AtLeast n) as expectedDistribution) -> + if Test.Distribution.Internal.insufficientlyCovered state.runsElapsed count (n / 100) then + Just ( onlyLabel, count, expectedDistribution ) - MoreThanZero -> - False + else + Nothing - AtLeast n -> - Test.Distribution.Internal.insufficientlyCovered state.runsElapsed count (n / 100) + Nothing -> + Nothing + + _ -> + Nothing ) + |> List.head |> Maybe.map (\( label, count, expectedDistribution ) -> { label = label From b5f84746059bcae920c3c724ee6fc0b1b039d0f2 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 14:21:44 +0100 Subject: [PATCH 023/123] Stop early --- src/MicroListExtra.elm | 16 ++++++++++++++++ src/Test/Fuzz.elm | 3 +-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/MicroListExtra.elm b/src/MicroListExtra.elm index 8c4408d6..d5f11eb7 100644 --- a/src/MicroListExtra.elm +++ b/src/MicroListExtra.elm @@ -2,6 +2,7 @@ module MicroListExtra exposing ( fastConcat , fastConcatMap , find + , findMap , getAt , setAt , splitWhen @@ -56,6 +57,21 @@ find predicate list = find predicate rest +findMap : (a -> Maybe b) -> List a -> Maybe b +findMap predicate list = + case list of + [] -> + Nothing + + first :: rest -> + case predicate first of + Nothing -> + findMap predicate rest + + justB -> + justB + + splitWhen : (a -> Bool) -> List a -> Maybe ( List a, List a ) splitWhen predicate list = findIndex predicate list diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index f2f794a7..2a69695c 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -348,7 +348,7 @@ findInsufficientlyCoveredLabel c state normalizedDistributionCount = distributionCount -- Needs normalized distribution count: |> Dict.toList - |> List.filterMap + |> List.findMap (\( labels, count ) -> case labels of [ onlyLabel ] -> @@ -372,7 +372,6 @@ findInsufficientlyCoveredLabel c state normalizedDistributionCount = _ -> Nothing ) - |> List.head |> Maybe.map (\( label, count, expectedDistribution ) -> { label = label From 8d265d4c75306a4fb33c76b576af05fe734423dc Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 14:22:10 +0100 Subject: [PATCH 024/123] Avoid Maybe.map --- src/Test/Fuzz.elm | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index 2a69695c..3c6aab19 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -361,7 +361,12 @@ findInsufficientlyCoveredLabel c state normalizedDistributionCount = Just ((AtLeast n) as expectedDistribution) -> if Test.Distribution.Internal.insufficientlyCovered state.runsElapsed count (n / 100) then - Just ( onlyLabel, count, expectedDistribution ) + Just + { label = onlyLabel + , actualPercentage = toFloat count * 100 / toFloat state.runsElapsed + , expectedDistribution = expectedDistribution + , runsElapsed = state.runsElapsed + } else Nothing @@ -372,14 +377,6 @@ findInsufficientlyCoveredLabel c state normalizedDistributionCount = _ -> Nothing ) - |> Maybe.map - (\( label, count, expectedDistribution ) -> - { label = label - , actualPercentage = toFloat count * 100 / toFloat state.runsElapsed - , expectedDistribution = expectedDistribution - , runsElapsed = state.runsElapsed - } - ) ) From 6c43a7e28b0d782295358f4f494e717228a1099e Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 14:23:22 +0100 Subject: [PATCH 025/123] Use more lazy case expressions --- src/Test/Fuzz.elm | 74 +++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index 3c6aab19..5cbdb90f 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -339,45 +339,49 @@ findBadZeroRelatedCase c state normalizedDistributionCount = findInsufficientlyCoveredLabel : LoopConstants a -> LoopState -> Maybe (Dict (List String) Int) -> Maybe DistributionFailure findInsufficientlyCoveredLabel c state normalizedDistributionCount = - Maybe.map2 Tuple.pair - normalizedDistributionCount - (Test.Distribution.Internal.getExpectedDistributions c.distribution) - |> Maybe.andThen - (\( distributionCount, expectedDistributions ) -> - -- TODO loop ExpectedDistributions instead of looping the label combinations? - distributionCount - -- Needs normalized distribution count: - |> Dict.toList - |> List.findMap - (\( labels, count ) -> - case labels of - [ onlyLabel ] -> - case Dict.get onlyLabel expectedDistributions of - Just Zero -> - Nothing - - Just MoreThanZero -> - Nothing - - Just ((AtLeast n) as expectedDistribution) -> - if Test.Distribution.Internal.insufficientlyCovered state.runsElapsed count (n / 100) then - Just - { label = onlyLabel - , actualPercentage = toFloat count * 100 / toFloat state.runsElapsed - , expectedDistribution = expectedDistribution - , runsElapsed = state.runsElapsed - } + case normalizedDistributionCount of + Nothing -> + Nothing - else + Just distributionCount -> + case Test.Distribution.Internal.getExpectedDistributions c.distribution of + Nothing -> + Nothing + + Just expectedDistributions -> + -- TODO loop ExpectedDistributions instead of looping the label combinations? + distributionCount + -- Needs normalized distribution count: + |> Dict.toList + |> List.findMap + (\( labels, count ) -> + case labels of + [ onlyLabel ] -> + case Dict.get onlyLabel expectedDistributions of + Just Zero -> Nothing - Nothing -> - Nothing + Just MoreThanZero -> + Nothing - _ -> - Nothing - ) - ) + Just ((AtLeast n) as expectedDistribution) -> + if Test.Distribution.Internal.insufficientlyCovered state.runsElapsed count (n / 100) then + Just + { label = onlyLabel + , actualPercentage = toFloat count * 100 / toFloat state.runsElapsed + , expectedDistribution = expectedDistribution + , runsElapsed = state.runsElapsed + } + + else + Nothing + + Nothing -> + Nothing + + _ -> + Nothing + ) distributionFailRunResult : Maybe (Dict (List String) Int) -> DistributionFailure -> RunResult From c32bfdbfa84ab2558dc8a6a93322a89f7fec38ac Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 14:24:20 +0100 Subject: [PATCH 026/123] Use more lazy case expressions --- src/Test/Fuzz.elm | 79 +++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index 5cbdb90f..f0dd3c8c 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -249,46 +249,51 @@ type alias DistributionFailure = allSufficientlyCovered : LoopConstants a -> LoopState -> Maybe (Dict (List String) Int) -> Bool allSufficientlyCovered c state normalizedDistributionCount = - Maybe.map2 Tuple.pair - normalizedDistributionCount - (Test.Distribution.Internal.getExpectedDistributions c.distribution) - |> Maybe.andThen - (\( distributionCount, expectedDistributions ) -> - distributionCount - -- Needs normalized distribution count: - |> Dict.toList - |> List.filterMap - (\( labels, count ) -> - case labels of - [ onlyLabel ] -> - Just ( onlyLabel, count ) - - _ -> - Nothing - ) - |> Maybe.traverse - (\( labels, count ) -> - Dict.get labels expectedDistributions - |> Maybe.map (\expectedDistribution -> ( count, expectedDistribution )) - ) - |> Maybe.map - (List.all - (\( count, expectedDistribution ) -> - case expectedDistribution of - -- Zero and MoreThanZero will get checked in the Success case - Zero -> - True + case normalizedDistributionCount of + Nothing -> + False - MoreThanZero -> - True + Just distributionCount -> + case Test.Distribution.Internal.getExpectedDistributions c.distribution of + Nothing -> + False - AtLeast n -> - Test.Distribution.Internal.sufficientlyCovered state.runsElapsed count (n / 100) + Just expectedDistributions -> + (distributionCount + -- Needs normalized distribution count: + |> Dict.toList + |> List.filterMap + (\( labels, count ) -> + case labels of + [ onlyLabel ] -> + Just ( onlyLabel, count ) + + _ -> + Nothing ) - ) - ) - -- `Nothing` means something went wrong. We're answering the question "are all labels sufficiently covered?" and so the way to fail here is `False`. - |> Maybe.withDefault False + |> Maybe.traverse + (\( labels, count ) -> + Dict.get labels expectedDistributions + |> Maybe.map (\expectedDistribution -> ( count, expectedDistribution )) + ) + |> Maybe.map + (List.all + (\( count, expectedDistribution ) -> + case expectedDistribution of + -- Zero and MoreThanZero will get checked in the Success case + Zero -> + True + + MoreThanZero -> + True + + AtLeast n -> + Test.Distribution.Internal.sufficientlyCovered state.runsElapsed count (n / 100) + ) + ) + ) + -- `Nothing` means something went wrong. We're answering the question "are all labels sufficiently covered?" and so the way to fail here is `False`. + |> Maybe.withDefault False findBadZeroRelatedCase : LoopConstants a -> LoopState -> Maybe (Dict (List String) Int) -> Maybe DistributionFailure From 0ab20eb250f4cc38fac5fde5b94d14082ee8f721 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 18:50:40 +0100 Subject: [PATCH 027/123] Avoid List.map --- src/Test/Distribution/Internal.elm | 4 ++-- src/Test/Fuzz.elm | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Test/Distribution/Internal.elm b/src/Test/Distribution/Internal.elm index c33eb48d..b6a05d46 100644 --- a/src/Test/Distribution/Internal.elm +++ b/src/Test/Distribution/Internal.elm @@ -51,7 +51,7 @@ getDistributionLabels distribution = Just (List.map (\( _, l, p ) -> ( l, p )) list) -getExpectedDistributionsAsList : Distribution a -> Maybe (List ( String, ExpectedDistribution )) +getExpectedDistributionsAsList : Distribution a -> Maybe (List ( ExpectedDistribution, String, a -> Bool )) getExpectedDistributionsAsList distribution = case distribution of NoDistributionNeeded -> @@ -61,7 +61,7 @@ getExpectedDistributionsAsList distribution = Nothing ExpectDistribution list -> - Just (List.map (\( e, l, _ ) -> ( l, e )) list) + Just list getExpectedDistributions : Distribution a -> Maybe (Dict String ExpectedDistribution) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index f0dd3c8c..73699659 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -310,7 +310,7 @@ findBadZeroRelatedCase c state normalizedDistributionCount = Just expectedDistributions -> expectedDistributions |> List.find - (\( label, expectedDistribution ) -> + (\( expectedDistribution, label, _ ) -> case expectedDistribution of Zero -> -- TODO short-circuit Zero sooner: as soon as we increment its counter, during runNTimes. @@ -329,7 +329,7 @@ findBadZeroRelatedCase c state normalizedDistributionCount = False ) |> Maybe.andThen - (\( label, expectedDistribution ) -> + (\( expectedDistribution, label, _ ) -> Dict.get [ label ] distributionCount |> Maybe.map (\count -> From 11620366ec35ab9d2d841fd92e049d87daab98ce Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 19:12:30 +0100 Subject: [PATCH 028/123] Faster Dict creation --- src/Test/Fuzz.elm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index 73699659..9d0e89f6 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -104,9 +104,10 @@ initLoopState initialSeed distribution = Test.Distribution.Internal.getDistributionLabels distribution |> Maybe.map (\labels -> - labels - |> List.map (\( label, _ ) -> ( [ label ], 0 )) - |> Dict.fromList + List.foldl + (\( label, _ ) dict -> Dict.insert [ label ] 0 dict) + Dict.empty + labels ) in { runsElapsed = 0 From 28ba13696068b4066a7921a286bf09a8b4294110 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 19:14:28 +0100 Subject: [PATCH 029/123] Avoid record --- src/Simplify/Cmd.elm | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index 6a99df99..b6a152ee 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -103,27 +103,29 @@ deletionCmds : Int -> List SimplifyCmd deletionCmds length = chunkCmds DeleteChunkAndMaybeDecrementPrevious - { length = length - , allowChunksOfSize1 = True - } + length + True zeroCmds : Int -> List SimplifyCmd zeroCmds length = chunkCmds ReplaceChunkWithZero - { length = length - , allowChunksOfSize1 = False -- already happens in binary search - } + length + False + + + +-- already happens in binary search sortCmds : Int -> List SimplifyCmd sortCmds length = chunkCmds SortChunk - { length = length - , allowChunksOfSize1 = False -- doesn't make sense for sorting - } + length + -- doesn't make sense for sorting + False minimizeChoiceCmds : RandomRun -> List SimplifyCmd @@ -248,9 +250,9 @@ swapCmds : Int -> List SimplifyCmd swapCmds length = chunkCmds SwapChunkWithNeighbour - { length = length - , allowChunksOfSize1 = False -- other Cmds are already doing the case with size=1 - } + length + False + -- other Cmds are already doing the case with size=1 |> List.map (\cmd -> case cmd.type_ of @@ -299,9 +301,10 @@ SortChunk { chunkSize = 8, startIndex = 2 } -- [..XXXXXXXX] -} chunkCmds : ({ size : Int, startIndex : Int } -> SimplifyCmdType) - -> { length : Int, allowChunksOfSize1 : Bool } + -> Int + -> Bool -> List SimplifyCmd -chunkCmds toType { length, allowChunksOfSize1 } = +chunkCmds toType length allowChunksOfSize1 = let initChunkSize : Int initChunkSize = From ee6ef3d354cb9e16ced9129c213671b60cfc6c71 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 19:24:48 +0100 Subject: [PATCH 030/123] Avoid double conversion from RandomRun to List --- src/Simplify/Cmd.elm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index b6a152ee..50be7fb5 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -86,12 +86,15 @@ cmdsForRun run = let length = RandomRun.length run + + randomRunList = + RandomRun.toList run in List.fastConcat [ deletionCmds length , zeroCmds length - , minimizeChoiceCmds run - , minimizeFloatCmds run length + , minimizeChoiceCmds randomRunList + , minimizeFloatCmds randomRunList length , sortCmds length , redistributeCmds length , decrementTogetherCmds length @@ -128,10 +131,9 @@ sortCmds length = False -minimizeChoiceCmds : RandomRun -> List SimplifyCmd +minimizeChoiceCmds : List Int -> List SimplifyCmd minimizeChoiceCmds run = run - |> RandomRun.toList |> List.indexedMap Tuple.pair |> List.filterMap (\( index, value ) -> @@ -147,13 +149,12 @@ minimizeChoiceCmds run = ) -minimizeFloatCmds : RandomRun -> Int -> List SimplifyCmd +minimizeFloatCmds : List Int -> Int -> List SimplifyCmd minimizeFloatCmds run length = let possibleBoolIndexes : Set Int possibleBoolIndexes = run - |> RandomRun.toList |> List.indexedMap Tuple.pair |> List.filterMap (\( index, value ) -> From 8e18d8f49504222c97d9066ddcee20cc359fc7e3 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 19:26:36 +0100 Subject: [PATCH 031/123] Extract function --- src/Simplify/Cmd.elm | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index 50be7fb5..1b42b1ab 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -154,17 +154,7 @@ minimizeFloatCmds run length = let possibleBoolIndexes : Set Int possibleBoolIndexes = - run - |> List.indexedMap Tuple.pair - |> List.filterMap - (\( index, value ) -> - if value > 1 then - Nothing - - else - Just index - ) - |> Set.fromList + computePossibleBoolIndexes run in List.range 0 (length - 3) |> List.filterMap @@ -180,6 +170,21 @@ minimizeFloatCmds run length = ) +computePossibleBoolIndexes : List Int -> Set Int +computePossibleBoolIndexes run = + run + |> List.indexedMap Tuple.pair + |> List.filterMap + (\( index, value ) -> + if value > 1 then + Nothing + + else + Just index + ) + |> Set.fromList + + decrementTogetherCmds : Int -> List SimplifyCmd decrementTogetherCmds length = let From cb1d2a2ef3d9395ab8812e7872cb018f43db40f6 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 19:28:40 +0100 Subject: [PATCH 032/123] Compute possible bool indexes using a single list traversal --- src/Simplify/Cmd.elm | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index 1b42b1ab..c5f06f0f 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -154,7 +154,7 @@ minimizeFloatCmds run length = let possibleBoolIndexes : Set Int possibleBoolIndexes = - computePossibleBoolIndexes run + computePossibleBoolIndexes 0 run Set.empty in List.range 0 (length - 3) |> List.filterMap @@ -170,19 +170,22 @@ minimizeFloatCmds run length = ) -computePossibleBoolIndexes : List Int -> Set Int -computePossibleBoolIndexes run = - run - |> List.indexedMap Tuple.pair - |> List.filterMap - (\( index, value ) -> - if value > 1 then - Nothing +computePossibleBoolIndexes : Int -> List Int -> Set Int -> Set Int +computePossibleBoolIndexes index run set = + case run of + [] -> + set - else - Just index - ) - |> Set.fromList + value :: rest -> + computePossibleBoolIndexes + (index + 1) + rest + (if value > 1 then + set + + else + Set.insert index set + ) decrementTogetherCmds : Int -> List SimplifyCmd From 96e4ec570466d52a83656b125a9d9fb01f7eccd8 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 1 Jan 2026 19:34:40 +0100 Subject: [PATCH 033/123] Compute minimizeFloatCmds using a single loop --- src/Simplify/Cmd.elm | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index c5f06f0f..21465d16 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -156,17 +156,25 @@ minimizeFloatCmds run length = possibleBoolIndexes = computePossibleBoolIndexes 0 run Set.empty in - List.range 0 (length - 3) - |> List.filterMap - (\index -> - if Set.member (index + 2) possibleBoolIndexes then - Just - { type_ = MinimizeFloat { leftIndex = index } - , minLength = index + 3 - } + minimizeFloatCmdsHelp possibleBoolIndexes (length - 3) [] - else - Nothing + +minimizeFloatCmdsHelp : Set Int -> Int -> List SimplifyCmd -> List SimplifyCmd +minimizeFloatCmdsHelp possibleBoolIndexes index list = + if index < 0 then + list + + else + minimizeFloatCmdsHelp possibleBoolIndexes + (index - 1) + (if Set.member (index + 2) possibleBoolIndexes then + { type_ = MinimizeFloat { leftIndex = index } + , minLength = index + 3 + } + :: list + + else + list ) From f3e3b88c09d9b433026be3dd0312939f5f453872 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Mon, 16 Feb 2026 09:46:32 +0100 Subject: [PATCH 034/123] Avoid redefining decoders in a lambda --- .../Html/Internal/ElmHtml/InternalTypes.elm | 48 +++++++++++++------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm index e54dfa3d..3ef54e15 100644 --- a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm +++ b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm @@ -435,32 +435,52 @@ decodeAttribute = |> Json.Decode.andThen (\tag -> if tag == Constants.attributeKey then - Json.Decode.map2 (\key val -> Attribute (AttributeRecord key val)) - (Json.Decode.field "n" Json.Decode.string) - (Json.Decode.field "o" Json.Decode.string) + attributeDecoder else if tag == Constants.attributeNamespaceKey then - Json.Decode.map3 NamespacedAttributeRecord - (Json.Decode.field "n" Json.Decode.string) - (Json.Decode.at [ "o", "o" ] Json.Decode.string) - (Json.Decode.at [ "o", "f" ] Json.Decode.string) - |> Json.Decode.map NamespacedAttribute + namespacedAttributeDecoder else if tag == Constants.styleKey then - Json.Decode.map2 (\key val -> Style { key = key, value = val }) - (Json.Decode.field "n" Json.Decode.string) - (Json.Decode.field "o" Json.Decode.string) + styleDecoder else if tag == Constants.propKey then - Json.Decode.map2 (\key val -> Property (PropertyRecord key val)) - (Json.Decode.field "n" Json.Decode.string) - (Json.Decode.at [ "o", "a" ] Json.Decode.value) + propertyDecoder else Json.Decode.fail ("Unexpected Html.Attribute tag: " ++ tag) ) +attributeDecoder : Json.Decode.Decoder Attribute +attributeDecoder = + Json.Decode.map2 (\key val -> Attribute (AttributeRecord key val)) + (Json.Decode.field "n" Json.Decode.string) + (Json.Decode.field "o" Json.Decode.string) + + +namespacedAttributeDecoder : Json.Decode.Decoder Attribute +namespacedAttributeDecoder = + Json.Decode.map3 NamespacedAttributeRecord + (Json.Decode.field "n" Json.Decode.string) + (Json.Decode.at [ "o", "o" ] Json.Decode.string) + (Json.Decode.at [ "o", "f" ] Json.Decode.string) + |> Json.Decode.map NamespacedAttribute + + +styleDecoder : Json.Decode.Decoder Attribute +styleDecoder = + Json.Decode.map2 (\key val -> Style { key = key, value = val }) + (Json.Decode.field "n" Json.Decode.string) + (Json.Decode.field "o" Json.Decode.string) + + +propertyDecoder : Json.Decode.Decoder Attribute +propertyDecoder = + Json.Decode.map2 (\key val -> Property (PropertyRecord key val)) + (Json.Decode.field "n" Json.Decode.string) + (Json.Decode.at [ "o", "a" ] Json.Decode.value) + + {-| A list of Void elements as defined by the HTML5 specification. These elements must not have closing tags and most not be written as self closing either From ffda4552bda563c604acdd6558d837a3166c9ee8 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Fri, 13 Feb 2026 22:04:43 +0100 Subject: [PATCH 035/123] Move map to the constants' declarations --- src/Test/Html/Internal/ElmHtml/InternalTypes.elm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm index 3ef54e15..2fd0661d 100644 --- a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm +++ b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm @@ -209,7 +209,7 @@ contextDecodeElmHtml context = |> Json.Decode.andThen (\nodeType -> if nodeType == kernelConstants.virtualDom.nodeTypeText then - Json.Decode.map TextTag decodeTextTag + decodeTextTag else if nodeType == kernelConstants.virtualDom.nodeTypeKeyedNode then Json.Decode.map NodeEntry (decodeKeyedNode context) @@ -233,10 +233,11 @@ contextDecodeElmHtml context = {-| decode text tag -} -decodeTextTag : Json.Decode.Decoder TextTagRecord +decodeTextTag : Json.Decode.Decoder (ElmHtml msg) decodeTextTag = field kernelConstants.virtualDom.text (Json.Decode.map (\text -> { text = text }) Json.Decode.string) + |> Json.Decode.map TextTag {-| decode a tagger From 3b66b4fb589ff1934c887eecbef7d2bd95555ad9 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Fri, 13 Feb 2026 22:10:56 +0100 Subject: [PATCH 036/123] Remove record for TextTag --- src/Test/Html/Internal/ElmHtml/InternalTypes.elm | 15 ++++----------- src/Test/Html/Internal/ElmHtml/Query.elm | 2 +- src/Test/Html/Internal/ElmHtml/ToString.elm | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm index 2fd0661d..0748a850 100644 --- a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm +++ b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm @@ -1,5 +1,5 @@ module Test.Html.Internal.ElmHtml.InternalTypes exposing - ( ElmHtml(..), TextTagRecord, NodeRecord, CustomNodeRecord, MarkdownNodeRecord + ( ElmHtml(..), NodeRecord, CustomNodeRecord, MarkdownNodeRecord , Facts, Tagger, EventHandler, ElementKind(..) , Attribute(..), AttributeRecord, NamespacedAttributeRecord, PropertyRecord, EventRecord , Validation(..), validationMessage, validationFromMessage @@ -8,7 +8,7 @@ module Test.Html.Internal.ElmHtml.InternalTypes exposing {-| Internal types used to represent Elm Html in pure Elm -@docs ElmHtml, TextTagRecord, NodeRecord, CustomNodeRecord, MarkdownNodeRecord +@docs ElmHtml, NodeRecord, CustomNodeRecord, MarkdownNodeRecord @docs Facts, Tagger, EventHandler, ElementKind @@ -38,18 +38,12 @@ import VirtualDom -} type ElmHtml msg - = TextTag TextTagRecord + = TextTag String | NodeEntry (NodeRecord msg) | CustomNode (CustomNodeRecord msg) | MarkdownNode (MarkdownNodeRecord msg) -{-| Text tags just contain text --} -type alias TextTagRecord = - { text : String } - - {-| A node contains the `tag` as a string, the children, the facts (e.g attributes) and descendantsCount -} type alias NodeRecord msg = @@ -236,8 +230,7 @@ contextDecodeElmHtml context = decodeTextTag : Json.Decode.Decoder (ElmHtml msg) decodeTextTag = field kernelConstants.virtualDom.text - (Json.Decode.map (\text -> { text = text }) Json.Decode.string) - |> Json.Decode.map TextTag + (Json.Decode.map TextTag Json.Decode.string) {-| decode a tagger diff --git a/src/Test/Html/Internal/ElmHtml/Query.elm b/src/Test/Html/Internal/ElmHtml/Query.elm index 3844ecbe..92af1c32 100644 --- a/src/Test/Html/Internal/ElmHtml/Query.elm +++ b/src/Test/Html/Internal/ElmHtml/Query.elm @@ -150,7 +150,7 @@ queryInNodeHelp maxDescendantDepth selector node = else childEntries - TextTag { text } -> + TextTag text -> case selector of ContainsText innerText -> if String.contains innerText text then diff --git a/src/Test/Html/Internal/ElmHtml/ToString.elm b/src/Test/Html/Internal/ElmHtml/ToString.elm index 4f0af21a..7f175147 100644 --- a/src/Test/Html/Internal/ElmHtml/ToString.elm +++ b/src/Test/Html/Internal/ElmHtml/ToString.elm @@ -35,7 +35,7 @@ defaultFormatOptions = nodeToLines : FormatOptions -> ElmHtml msg -> List String nodeToLines options nodeType = case nodeType of - TextTag { text } -> + TextTag text -> [ text ] NodeEntry record -> From 110fb84f9d57f4cd70815ed59950e43d52dfde6c Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 00:15:52 +0100 Subject: [PATCH 037/123] Make toLinesHelp tail-call recursive --- src/Test/Html/Query/Internal.elm | 55 ++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/src/Test/Html/Query/Internal.elm b/src/Test/Html/Query/Internal.elm index 96006123..849e83a8 100644 --- a/src/Test/Html/Query/Internal.elm +++ b/src/Test/Html/Query/Internal.elm @@ -105,14 +105,6 @@ toLinesHelp expectationFailure elmHtmlList selectorQueries queryName results = -- sees is Query.find rather than something like -- Query.has, to reflect how we didn't make it that far. String.join "\n\n\n✗ " [ result, expectationFailure ] :: results - - recurse newElmHtmlList rest result = - toLinesHelp - expectationFailure - newElmHtmlList - rest - queryName - (result :: results) in case selectorQueries of [] -> @@ -126,10 +118,17 @@ toLinesHelp expectationFailure elmHtmlList selectorQueries queryName results = elmHtmlList |> List.concatMap getChildren |> InternalSelector.queryAll selectors + + result = + ("Query.findAll " ++ joinAsList selectorToString selectors) + |> withHtmlContext (getHtmlContext elements) in - ("Query.findAll " ++ joinAsList selectorToString selectors) - |> withHtmlContext (getHtmlContext elements) - |> recurse elements rest + toLinesHelp + expectationFailure + elements + rest + queryName + (result :: results) Find selectors -> let @@ -143,7 +142,12 @@ toLinesHelp expectationFailure elmHtmlList selectorQueries queryName results = |> withHtmlContext (getHtmlContext elements) in if List.length elements == 1 then - recurse elements rest result + toLinesHelp + expectationFailure + elements + rest + queryName + (result :: results) else bailOut result @@ -154,10 +158,17 @@ toLinesHelp expectationFailure elmHtmlList selectorQueries queryName results = elmHtmlList |> List.concatMap getChildren |> InternalSelector.queryAllChildren selectors + + result = + ("Query.children " ++ joinAsList selectorToString selectors) + |> withHtmlContext (getHtmlContext elements) in - ("Query.children " ++ joinAsList selectorToString selectors) - |> withHtmlContext (getHtmlContext elements) - |> recurse elements rest + toLinesHelp + expectationFailure + elements + rest + queryName + (result :: results) First -> let @@ -172,7 +183,12 @@ toLinesHelp expectationFailure elmHtmlList selectorQueries queryName results = |> withHtmlContext (getHtmlContext elements) in if List.length elements == 1 then - recurse elements rest result + toLinesHelp + expectationFailure + elements + rest + queryName + (result :: results) else bailOut result @@ -188,7 +204,12 @@ toLinesHelp expectationFailure elmHtmlList selectorQueries queryName results = |> withHtmlContext (getHtmlContext elements) in if List.length elements == 1 then - recurse elements rest result + toLinesHelp + expectationFailure + elements + rest + queryName + (result :: results) else bailOut result From 5153874e9058e373f65695d023bd6fe8371187b3 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 00:20:35 +0100 Subject: [PATCH 038/123] Faster withHtmlContext --- src/Test/Html/Query/Internal.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Test/Html/Query/Internal.elm b/src/Test/Html/Query/Internal.elm index 849e83a8..f888d366 100644 --- a/src/Test/Html/Query/Internal.elm +++ b/src/Test/Html/Query/Internal.elm @@ -217,7 +217,7 @@ toLinesHelp expectationFailure elmHtmlList selectorQueries queryName results = withHtmlContext : String -> String -> String withHtmlContext htmlStr str = - String.join "\n\n" [ str, htmlStr ] + str ++ "\n\n" ++ htmlStr getHtmlContext : List (ElmHtml msg) -> String From a83197ad4da03bd1c95ccd99d483e5fabcde3760 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 00:28:39 +0100 Subject: [PATCH 039/123] Make joinAsList faster --- src/Test/Html/Query/Internal.elm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Test/Html/Query/Internal.elm b/src/Test/Html/Query/Internal.elm index f888d366..7006b3ed 100644 --- a/src/Test/Html/Query/Internal.elm +++ b/src/Test/Html/Query/Internal.elm @@ -240,11 +240,12 @@ getHtmlContext elmHtmlList = joinAsList : (a -> String) -> List a -> String joinAsList toStr list = - if List.isEmpty list then - "[]" + case list of + [] -> + "[]" - else - "[ " ++ String.join ", " (List.map toStr list) ++ " ]" + first :: tail -> + List.foldl (\x str -> str ++ ", " ++ toStr x) ("[ " ++ toStr first) tail ++ " ]" printIndented : Int -> Int -> ElmHtml msg -> String From 37a5d9c9b751f281a8f0ce28c73476c92f9cfe89 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 00:37:53 +0100 Subject: [PATCH 040/123] Compute trimmedExtras in a single list iteration --- src/Test/Html/Internal/ElmHtml/ToString.elm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/ToString.elm b/src/Test/Html/Internal/ElmHtml/ToString.elm index 7f175147..28e8ca0e 100644 --- a/src/Test/Html/Internal/ElmHtml/ToString.elm +++ b/src/Test/Html/Internal/ElmHtml/ToString.elm @@ -80,9 +80,7 @@ nodeRecordToString options { tag, children, facts } = openTag extras = let trimmedExtras = - List.filterMap (\x -> x) extras - |> List.map String.trim - |> List.filter ((/=) "") + List.filterMap (Maybe.andThen (String.trim >> nothingIfEmpty)) extras filling = case trimmedExtras of @@ -154,3 +152,12 @@ nodeRecordToString options { tag, children, facts } = openTag [ classes, styles, stringAttributes, boolAttributes ] :: childrenStrings ++ [ closeTag ] + + +nothingIfEmpty : String -> Maybe String +nothingIfEmpty str = + if str == "" then + Nothing + + else + Just str From cd10e72a06315ce17f6fe0a6db9da924f696d8ee Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 00:40:15 +0100 Subject: [PATCH 041/123] Compute styles in a single collection iteration --- src/Test/Html/Internal/ElmHtml/ToString.elm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/ToString.elm b/src/Test/Html/Internal/ElmHtml/ToString.elm index 28e8ca0e..89bd1049 100644 --- a/src/Test/Html/Internal/ElmHtml/ToString.elm +++ b/src/Test/Html/Internal/ElmHtml/ToString.elm @@ -93,16 +93,16 @@ nodeRecordToString options { tag, children, facts } = "<" ++ tag ++ filling ++ ">" styles = - case Dict.toList facts.styles of - [] -> - Nothing - - styleValues -> - styleValues - |> List.map (\( key, value ) -> key ++ ":" ++ value ++ ";") - |> String.join "" - |> (\styleString -> "style=\"" ++ styleString ++ "\"") - |> Just + if Dict.isEmpty facts.styles then + Nothing + + else + let + styleString : String + styleString = + Dict.foldl (\key value str -> str ++ key ++ ":" ++ value ++ ";") "" facts.styles + in + Just ("style=\"" ++ styleString ++ "\"") classes = Dict.get "className" facts.stringAttributes From 3d1291dba3cbfdff5466fcd0a9c67df095f5d8db Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 00:41:58 +0100 Subject: [PATCH 042/123] Compute stringAttributes in a single collection iteration --- src/Test/Html/Internal/ElmHtml/ToString.elm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/ToString.elm b/src/Test/Html/Internal/ElmHtml/ToString.elm index 89bd1049..e2c7e05e 100644 --- a/src/Test/Html/Internal/ElmHtml/ToString.elm +++ b/src/Test/Html/Internal/ElmHtml/ToString.elm @@ -109,10 +109,17 @@ nodeRecordToString options { tag, children, facts } = |> Maybe.map (\name -> "class=\"" ++ name ++ "\"") stringAttributes = - Dict.filter (\k _ -> k /= "className") facts.stringAttributes - |> Dict.toList - |> List.map (\( k, v ) -> k ++ "=\"" ++ v ++ "\"") - |> String.join " " + Dict.foldl + (\k v str -> + if k == "className" then + str + + else + str ++ " " ++ k ++ "=\"" ++ v ++ "\"" + ) + "" + facts.stringAttributes + |> String.trimLeft |> Just boolAttributes = From 155dfd1535b9645f89f04818b917a28ca8fc0acc Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 00:43:14 +0100 Subject: [PATCH 043/123] Compute boolAttributes in a single collection iteration --- src/Test/Html/Internal/ElmHtml/ToString.elm | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/ToString.elm b/src/Test/Html/Internal/ElmHtml/ToString.elm index e2c7e05e..d2fb125c 100644 --- a/src/Test/Html/Internal/ElmHtml/ToString.elm +++ b/src/Test/Html/Internal/ElmHtml/ToString.elm @@ -123,16 +123,17 @@ nodeRecordToString options { tag, children, facts } = |> Just boolAttributes = - Dict.toList facts.boolAttributes - |> List.filterMap - (\( k, v ) -> - if v then - Just k - - else - Nothing - ) - |> String.join " " + Dict.foldl + (\k v str -> + if v then + str ++ " " ++ k + + else + str + ) + "" + facts.boolAttributes + |> String.trimLeft |> Just in case toElementKind tag of From 6af438b0fe12dcb2534bdafdb586e7dd1e871d23 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 00:44:02 +0100 Subject: [PATCH 044/123] Extract openTag computation --- src/Test/Html/Internal/ElmHtml/ToString.elm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/ToString.elm b/src/Test/Html/Internal/ElmHtml/ToString.elm index d2fb125c..eba1ac6b 100644 --- a/src/Test/Html/Internal/ElmHtml/ToString.elm +++ b/src/Test/Html/Internal/ElmHtml/ToString.elm @@ -135,13 +135,17 @@ nodeRecordToString options { tag, children, facts } = facts.boolAttributes |> String.trimLeft |> Just + + openTag_ : String + openTag_ = + openTag [ classes, styles, stringAttributes, boolAttributes ] in case toElementKind tag of {- Void elements only have a start tag; end tags must not be specified for void elements. -} VoidElements -> - [ openTag [ classes, styles, stringAttributes, boolAttributes ] ] + [ openTag_ ] {- TODO: implement restrictions for RawTextElements, EscapableRawTextElements. Also handle ForeignElements correctly. @@ -157,7 +161,7 @@ nodeRecordToString options { tag, children, facts } = List.concatMap (nodeToLines options) children |> List.map ((++) (String.repeat options.indent " ")) in - openTag [ classes, styles, stringAttributes, boolAttributes ] + openTag_ :: childrenStrings ++ [ closeTag ] From b369457093ece129f21e141df4d439e9a5146ecf Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 00:47:14 +0100 Subject: [PATCH 045/123] Extract value --- src/Test/Html/Internal/ElmHtml/ToString.elm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Test/Html/Internal/ElmHtml/ToString.elm b/src/Test/Html/Internal/ElmHtml/ToString.elm index eba1ac6b..c373843f 100644 --- a/src/Test/Html/Internal/ElmHtml/ToString.elm +++ b/src/Test/Html/Internal/ElmHtml/ToString.elm @@ -157,9 +157,13 @@ nodeRecordToString options { tag, children, facts } = closeTag = "" + indent : String + indent = + String.repeat options.indent " " + childrenStrings = List.concatMap (nodeToLines options) children - |> List.map ((++) (String.repeat options.indent " ")) + |> List.map ((++) indent) in openTag_ :: childrenStrings From 4faf6944365871cd34ea839d94314b91a913d950 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 00:47:31 +0100 Subject: [PATCH 046/123] Use explicit lambda --- src/Test/Html/Internal/ElmHtml/ToString.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Test/Html/Internal/ElmHtml/ToString.elm b/src/Test/Html/Internal/ElmHtml/ToString.elm index c373843f..07896745 100644 --- a/src/Test/Html/Internal/ElmHtml/ToString.elm +++ b/src/Test/Html/Internal/ElmHtml/ToString.elm @@ -163,7 +163,7 @@ nodeRecordToString options { tag, children, facts } = childrenStrings = List.concatMap (nodeToLines options) children - |> List.map ((++) indent) + |> List.map (\x -> indent ++ x ++ "") in openTag_ :: childrenStrings From 8b6a78d203eac2af89f19682c1d127e612522ebd Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 00:48:19 +0100 Subject: [PATCH 047/123] Avoid adding to the end --- src/Test/Html/Internal/ElmHtml/ToString.elm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/ToString.elm b/src/Test/Html/Internal/ElmHtml/ToString.elm index 07896745..7585f2ae 100644 --- a/src/Test/Html/Internal/ElmHtml/ToString.elm +++ b/src/Test/Html/Internal/ElmHtml/ToString.elm @@ -163,11 +163,9 @@ nodeRecordToString options { tag, children, facts } = childrenStrings = List.concatMap (nodeToLines options) children - |> List.map (\x -> indent ++ x ++ "") + |> List.foldr (\x list -> (indent ++ x ++ "") :: list) [ closeTag ] in - openTag_ - :: childrenStrings - ++ [ closeTag ] + openTag_ :: childrenStrings nothingIfEmpty : String -> Maybe String From 6e3f2f19f0a4561c7e150c52691390bdb9c1475d Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 10:04:37 +0100 Subject: [PATCH 048/123] Merge definitions --- src/Test/Html/Internal/ElmHtml/Query.elm | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/Query.elm b/src/Test/Html/Internal/ElmHtml/Query.elm index 92af1c32..27aa2297 100644 --- a/src/Test/Html/Internal/ElmHtml/Query.elm +++ b/src/Test/Html/Internal/ElmHtml/Query.elm @@ -85,11 +85,12 @@ queryByBoolAttribute key value = query (BoolAttribute key value) -{-| Query an ElmHtml element using a selector, searching all children. +{-| Query an ElmHtml node using a selector, considering both the node itself +as well as all of its descendants. -} query : Selector -> ElmHtml msg -> List (ElmHtml msg) query selector = - queryInNode selector + queryInNodeHelp Nothing selector {-| Query an ElmHtml node using multiple selectors, considering both the node itself @@ -100,14 +101,6 @@ queryAll selectors = query (Multiple selectors) -{-| Query an ElmHtml node using a selector, considering both the node itself -as well as all of its descendants. --} -queryInNode : Selector -> ElmHtml msg -> List (ElmHtml msg) -queryInNode = - queryInNodeHelp Nothing - - {-| Query an ElmHtml node using a selector, considering both the node itself as well as all of its descendants. -} From 0f3adf84f280c813a64b7813ddd5f8e5171ffacb Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 10:04:47 +0100 Subject: [PATCH 049/123] Rename function --- src/Test/Html/Internal/ElmHtml/Query.elm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/Query.elm b/src/Test/Html/Internal/ElmHtml/Query.elm index 27aa2297..5b06f1ab 100644 --- a/src/Test/Html/Internal/ElmHtml/Query.elm +++ b/src/Test/Html/Internal/ElmHtml/Query.elm @@ -90,7 +90,7 @@ as well as all of its descendants. -} query : Selector -> ElmHtml msg -> List (ElmHtml msg) query selector = - queryInNodeHelp Nothing selector + queryInNode Nothing selector {-| Query an ElmHtml node using multiple selectors, considering both the node itself @@ -106,7 +106,7 @@ as well as all of its descendants. -} queryChildren : Selector -> ElmHtml msg -> List (ElmHtml msg) queryChildren = - queryInNodeHelp (Just 1) + queryInNode (Just 1) {-| Returns just the immediate children of an ElmHtml node @@ -126,11 +126,11 @@ any descendants lower than its immediate children. -} queryChildrenAll : List Selector -> ElmHtml msg -> List (ElmHtml msg) queryChildrenAll selectors = - queryInNodeHelp (Just 1) (Multiple selectors) + queryInNode (Just 1) (Multiple selectors) -queryInNodeHelp : Maybe Int -> Selector -> ElmHtml msg -> List (ElmHtml msg) -queryInNodeHelp maxDescendantDepth selector node = +queryInNode : Maybe Int -> Selector -> ElmHtml msg -> List (ElmHtml msg) +queryInNode maxDescendantDepth selector node = case node of NodeEntry record -> let @@ -179,14 +179,14 @@ descendInQuery maxDescendantDepth selector children = Nothing -> -- No maximum, so continue. List.concatMap - (queryInNodeHelp Nothing selector) + (queryInNode Nothing selector) children Just depth -> if depth > 0 then -- Continue with maximum depth reduced by 1. List.concatMap - (queryInNodeHelp (Just (depth - 1)) selector) + (queryInNode (Just (depth - 1)) selector) children else From c110a449f043b78938c1685c119b66a3b2296cf8 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Wed, 18 Feb 2026 14:46:01 +0100 Subject: [PATCH 050/123] Remove unused code --- src/Queue.elm | 117 +----------------- .../Html/Internal/ElmHtml/InternalTypes.elm | 19 +-- src/Test/Html/Internal/ElmHtml/Query.elm | 65 ---------- src/Test/Html/Internal/ElmHtml/ToString.elm | 16 --- src/Test/Html/Query/Internal.elm | 10 -- tests/src/Test/Html/ExampleApp.elm | 11 +- tests/src/Test/Html/ExampleAppTests.elm | 2 +- 7 files changed, 8 insertions(+), 232 deletions(-) diff --git a/src/Queue.elm b/src/Queue.elm index eb9c92b3..7ca2d68e 100644 --- a/src/Queue.elm +++ b/src/Queue.elm @@ -1,8 +1,7 @@ module Queue exposing - ( Queue, empty, singleton - , isEmpty, size, enqueue, dequeue, front + ( Queue, empty + , enqueue, dequeue , fromList, toList - , map, filter, updateFront ) {-| NOTE: Vendored from turboMaCk/queue 1.1.0 @@ -14,12 +13,12 @@ Queue is simple FIFO (first in, first out) datastructure. # Type -@docs Queue, empty, singleton +@docs Queue, empty # Query -@docs isEmpty, size, enqueue, dequeue, front +@docs enqueue, dequeue # Lists @@ -29,8 +28,6 @@ Queue is simple FIFO (first in, first out) datastructure. # Transformations -@docs map, filter, updateFront - -} -- Types @@ -74,44 +71,10 @@ empty = Queue [] [] -{-| Construct Queue containing single value - - Queue.toList (Queue.singleton 1) == [ 1 ] - --} -singleton : a -> Queue a -singleton a = - Queue [ a ] [] - - -- Query -{-| Determine if `Queue` is empty - - Queue.isEmpty Queue.empty == True - - Queue.isEmpty (Queue.fromList [ 1, 2 ]) == False - --} -isEmpty : Queue a -> Bool -isEmpty (Queue fl rl) = - List.isEmpty fl && List.isEmpty rl - - -{-| Get size of `Queue` - - Queue.size Queue.empty == 0 - - Queue.size (Queue.fromList [ 1, 2 ]) == 2 - --} -size : Queue a -> Int -size (Queue fl rl) = - List.length fl + List.length rl - - {-| Add item to `Queue` Queue.size (Queue.enqueue 1 Queue.empty) == 1 @@ -141,46 +104,6 @@ dequeue (Queue fl rl) = ( Just head, queue tail rl ) -{-| Ask for front item without removing it from `Queue` - - Queue.front Queue.empty == Nothing - - Queue.front (Queue.fromList [ 1, 2 ]) == Just 1 - --} -front : Queue a -> Maybe a -front (Queue fl _) = - List.head fl - - -{-| Update value at the front of the queue - - Queue.toList (Queue.updateFront (Maybe.map (\x -> x + 1)) (Queue.singleton 3)) == [ 4 ] - - Queue.toList (Queue.updateFront (Maybe.map (\_ -> Just 42)) Queue.empty) == [ 42 ] - - Queue.toList (Queue.updateFront (Maybe.map (\_ -> Nothing)) (Queue.singleton 3)) == [] - --} -updateFront : (Maybe a -> Maybe a) -> Queue a -> Queue a -updateFront f (Queue fl rl) = - let - update_ maybe t = - case f maybe of - Just a -> - a :: t - - Nothing -> - t - in - case fl of - h :: t -> - Queue (update_ (Just h) t) rl - - [] -> - Queue (update_ Nothing []) rl - - -- Lists @@ -211,35 +134,3 @@ toList (Queue fl rl) = -- Transform - - -{-| Map function over `Queue` - - Queue.toList (Queue.map identity (Queue.fromList [ 1, 2 ])) == [ 1, 2 ] - - Queue.toList (Queue.map ((+) 1) (Queue.fromList [ 1, 2 ])) == [ 2, 3 ] - --} -map : (a -> b) -> Queue a -> Queue b -map fc (Queue fl rl) = - let - map_ = - List.map fc - in - queue (map_ fl) (map_ rl) - - -{-| Filter items items in `Queue` - - Queue.toList (Queue.filter identity (Queue.fromList [ True, False ])) == [ True ] - - Queue.toList (Queue.filter ((<) 1) (Queue.fromList [ 1, 2 ])) == [ 2 ] - --} -filter : (a -> Bool) -> Queue a -> Queue a -filter fc (Queue fl rl) = - let - f = - List.filter fc - in - queue (f fl) (f rl) diff --git a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm index 0748a850..953cf9e2 100644 --- a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm +++ b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm @@ -1,7 +1,7 @@ module Test.Html.Internal.ElmHtml.InternalTypes exposing ( ElmHtml(..), NodeRecord, CustomNodeRecord, MarkdownNodeRecord , Facts, Tagger, EventHandler, ElementKind(..) - , Attribute(..), AttributeRecord, NamespacedAttributeRecord, PropertyRecord, EventRecord + , Attribute(..), AttributeRecord, NamespacedAttributeRecord, PropertyRecord , Validation(..), validationMessage, validationFromMessage , decodeElmHtml, toElementKind, decodeAttribute ) @@ -12,7 +12,7 @@ module Test.Html.Internal.ElmHtml.InternalTypes exposing @docs Facts, Tagger, EventHandler, ElementKind -@docs Attribute, AttributeRecord, NamespacedAttributeRecord, PropertyRecord, EventRecord +@docs Attribute, AttributeRecord, NamespacedAttributeRecord, PropertyRecord @docs Validation, validationMessage, validationFromMessage @@ -168,21 +168,6 @@ type alias PropertyRecord = } -{-| Event contains a string key, a decoder for a msg and event options --} -type alias EventRecord = - { key : String - , decoder : Json.Decode.Value - , options : EventOptions - } - - -type alias EventOptions = - { stopPropagation : Bool - , preventDefault : Bool - } - - {-| decode a json object into ElmHtml, you have to pass a function that decodes events from Html Nodes. If you don't want to decode event msgs, you can ignore it: diff --git a/src/Test/Html/Internal/ElmHtml/Query.elm b/src/Test/Html/Internal/ElmHtml/Query.elm index 5b06f1ab..bbc59292 100644 --- a/src/Test/Html/Internal/ElmHtml/Query.elm +++ b/src/Test/Html/Internal/ElmHtml/Query.elm @@ -36,55 +36,6 @@ type Selector | Multiple (List Selector) -{-| Query for a node with a given tag in a Html element --} -queryByTagName : String -> ElmHtml msg -> List (ElmHtml msg) -queryByTagName tagname = - query (Tag tagname) - - -{-| Query for a node with a given id in a Html element --} -queryById : String -> ElmHtml msg -> List (ElmHtml msg) -queryById id = - query (Id id) - - -{-| Query for a node with a given classname in a Html element --} -queryByClassName : String -> ElmHtml msg -> List (ElmHtml msg) -queryByClassName classname = - query (ClassName classname) - - -{-| Query for a node with all the given classnames in a Html element --} -queryByClassList : List String -> ElmHtml msg -> List (ElmHtml msg) -queryByClassList classList = - query (ClassList classList) - - -{-| Query for a node with the given style in a Html element --} -queryByStyle : { key : String, value : String } -> ElmHtml msg -> List (ElmHtml msg) -queryByStyle style = - query (Style style) - - -{-| Query for a node with a given attribute in a Html element --} -queryByAttribute : String -> String -> ElmHtml msg -> List (ElmHtml msg) -queryByAttribute key value = - query (Attribute key value) - - -{-| Query for a node with a given attribute in a Html element --} -queryByBoolAttribute : String -> Bool -> ElmHtml msg -> List (ElmHtml msg) -queryByBoolAttribute key value = - query (BoolAttribute key value) - - {-| Query an ElmHtml node using a selector, considering both the node itself as well as all of its descendants. -} @@ -93,14 +44,6 @@ query selector = queryInNode Nothing selector -{-| Query an ElmHtml node using multiple selectors, considering both the node itself -as well as all of its descendants. --} -queryAll : List Selector -> ElmHtml msg -> List (ElmHtml msg) -queryAll selectors = - query (Multiple selectors) - - {-| Query an ElmHtml node using a selector, considering both the node itself as well as all of its descendants. -} @@ -121,14 +64,6 @@ getChildren elmHtml = [] -{-| Query to ensure an ElmHtml node has all selectors given, without considering -any descendants lower than its immediate children. --} -queryChildrenAll : List Selector -> ElmHtml msg -> List (ElmHtml msg) -queryChildrenAll selectors = - queryInNode (Just 1) (Multiple selectors) - - queryInNode : Maybe Int -> Selector -> ElmHtml msg -> List (ElmHtml msg) queryInNode maxDescendantDepth selector node = case node of diff --git a/src/Test/Html/Internal/ElmHtml/ToString.elm b/src/Test/Html/Internal/ElmHtml/ToString.elm index 7585f2ae..47069b87 100644 --- a/src/Test/Html/Internal/ElmHtml/ToString.elm +++ b/src/Test/Html/Internal/ElmHtml/ToString.elm @@ -23,15 +23,6 @@ type alias FormatOptions = } -{-| default formatting options --} -defaultFormatOptions : FormatOptions -defaultFormatOptions = - { indent = 0 - , newLines = False - } - - nodeToLines : FormatOptions -> ElmHtml msg -> List String nodeToLines options nodeType = case nodeType of @@ -48,13 +39,6 @@ nodeToLines options nodeType = [ record.model.markdown ] -{-| Convert a given html node to a string based on the type --} -nodeToString : ElmHtml msg -> String -nodeToString = - nodeToStringWithOptions defaultFormatOptions - - {-| same as nodeToString, but with options -} nodeToStringWithOptions : FormatOptions -> ElmHtml msg -> String diff --git a/src/Test/Html/Query/Internal.elm b/src/Test/Html/Query/Internal.elm index 7006b3ed..454294ba 100644 --- a/src/Test/Html/Query/Internal.elm +++ b/src/Test/Html/Query/Internal.elm @@ -407,16 +407,6 @@ getChildren elmHtml = [] -isElement : ElmHtml msg -> Bool -isElement elmHtml = - case elmHtml of - NodeEntry _ -> - True - - _ -> - False - - verifySingle : String -> List a -> Result QueryError a verifySingle queryName list = case list of diff --git a/tests/src/Test/Html/ExampleApp.elm b/tests/src/Test/Html/ExampleApp.elm index c1e64d0f..2fc356a8 100644 --- a/tests/src/Test/Html/ExampleApp.elm +++ b/tests/src/Test/Html/ExampleApp.elm @@ -1,4 +1,4 @@ -module Test.Html.ExampleApp exposing (exampleModel, view) +module Test.Html.ExampleApp exposing (view) import Html exposing (..) import Html.Attributes exposing (..) @@ -7,15 +7,6 @@ import Html.Keyed as Keyed import Html.Lazy as Lazy -type alias Model = - () - - -exampleModel : Model -exampleModel = - () - - type Msg = GoToHome | GoToExamples diff --git a/tests/src/Test/Html/ExampleAppTests.elm b/tests/src/Test/Html/ExampleAppTests.elm index 8dd0533b..919572ab 100644 --- a/tests/src/Test/Html/ExampleAppTests.elm +++ b/tests/src/Test/Html/ExampleAppTests.elm @@ -3,7 +3,7 @@ module Test.Html.ExampleAppTests exposing (all) import Expect import Html.Attributes exposing (href) import Test exposing (..) -import Test.Html.ExampleApp exposing (exampleModel, view) +import Test.Html.ExampleApp exposing (view) import Test.Html.Query as Query import Test.Html.Selector exposing (..) From 7fd74c1dd253dbd2b5d6b73093d75ffd0a284c4e Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 10:11:41 +0100 Subject: [PATCH 051/123] Remove unused code --- src/Test/Html/Internal/ElmHtml/Query.elm | 41 +----------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/Query.elm b/src/Test/Html/Internal/ElmHtml/Query.elm index bbc59292..3fd8877b 100644 --- a/src/Test/Html/Internal/ElmHtml/Query.elm +++ b/src/Test/Html/Internal/ElmHtml/Query.elm @@ -24,16 +24,13 @@ import Test.Html.Internal.ElmHtml.InternalTypes exposing (..) -} type Selector - = Id String - | ClassName String - | ClassList (List String) + = ClassList (List String) | Tag String | Attribute String String | BoolAttribute String Bool | Style { key : String, value : String } | ContainsText String | ContainsExactText String - | Multiple (List Selector) {-| Query an ElmHtml node using a selector, considering both the node itself @@ -143,13 +140,6 @@ predicateFromSelector selector html = False -hasAllSelectors : List Selector -> ElmHtml msg -> Bool -hasAllSelectors selectors record = - List.map predicateFromSelector selectors - |> List.map (\selector -> selector record) - |> List.all identity - - hasAttribute : String -> String -> Facts msg -> Bool hasAttribute attribute queryString facts = case Dict.get attribute facts.stringAttributes of @@ -170,11 +160,6 @@ hasBoolAttribute attribute value facts = False -hasClass : String -> Facts msg -> Bool -hasClass queryString facts = - List.member queryString (classnames facts) - - hasClasses : List String -> Facts msg -> Bool hasClasses classList facts = containsAll classList (classnames facts) @@ -227,14 +212,6 @@ containsAll a b = nodeRecordPredicate : Selector -> (NodeRecord msg -> Bool) nodeRecordPredicate selector = case selector of - Id id -> - .facts - >> hasAttribute "id" id - - ClassName classname -> - .facts - >> hasClass classname - ClassList classList -> .facts >> hasClasses classList @@ -261,22 +238,10 @@ nodeRecordPredicate selector = ContainsExactText _ -> always False - Multiple selectors -> - NodeEntry - >> hasAllSelectors selectors - markdownPredicate : Selector -> (MarkdownNodeRecord msg -> Bool) markdownPredicate selector = case selector of - Id id -> - .facts - >> hasAttribute "id" id - - ClassName classname -> - .facts - >> hasClass classname - ClassList classList -> .facts >> hasClasses classList @@ -305,7 +270,3 @@ markdownPredicate selector = .model >> .markdown >> (==) text - - Multiple selectors -> - MarkdownNode - >> hasAllSelectors selectors From 1afc2f4054b6b82b1586f751cc295937002412d8 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 10:13:30 +0100 Subject: [PATCH 052/123] Remove unnecessary parameters --- src/Test/Html/Selector.elm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Test/Html/Selector.elm b/src/Test/Html/Selector.elm index a61505e5..6a7dbe8a 100644 --- a/src/Test/Html/Selector.elm +++ b/src/Test/Html/Selector.elm @@ -177,8 +177,8 @@ id = -} tag : String -> Selector -tag name = - Tag name +tag = + Tag {-| Matches elements that have the given attribute in a way that makes sense From 6db72ad825ca70529464b164939eebc972fc44e5 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 10:15:27 +0100 Subject: [PATCH 053/123] Add padding argument to Selector type This is done so that all variants have the same shape, which makes for better performance. --- src/Test/Html/Selector.elm | 6 +++--- src/Test/Html/Selector/Internal.elm | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Test/Html/Selector.elm b/src/Test/Html/Selector.elm index 6a7dbe8a..5cc3c76c 100644 --- a/src/Test/Html/Selector.elm +++ b/src/Test/Html/Selector.elm @@ -214,16 +214,16 @@ attribute attr = |> Json.Decode.decodeValue Json.Decode.bool |> Result.map (namedBoolAttr key) ) - |> Result.withDefault Invalid + |> Result.withDefault Internal.invalid Ok (InternalTypes.Style { key, value }) -> Style { key = key, value = value } Ok (InternalTypes.NamespacedAttribute _) -> - Invalid + Internal.invalid Err _ -> - Invalid + Internal.invalid {-| Matches elements that have the given style properties (and possibly others as well). diff --git a/src/Test/Html/Selector/Internal.elm b/src/Test/Html/Selector/Internal.elm index d0e6b541..77fd2c34 100644 --- a/src/Test/Html/Selector/Internal.elm +++ b/src/Test/Html/Selector/Internal.elm @@ -1,4 +1,4 @@ -module Test.Html.Selector.Internal exposing (Selector(..), hasAll, namedAttr, namedBoolAttr, queryAll, queryAllChildren, selectorToString) +module Test.Html.Selector.Internal exposing (Selector(..), hasAll, invalid, namedAttr, namedBoolAttr, queryAll, queryAllChildren, selectorToString) import Test.Html.Internal.ElmHtml.InternalTypes exposing (ElmHtml) import Test.Html.Internal.ElmHtml.Query as ElmHtmlQuery @@ -15,7 +15,12 @@ type Selector | Text String | ExactText String | Containing (List Selector) - | Invalid + | Invalid () + + +invalid : Selector +invalid = + Invalid () selectorToString : Selector -> String @@ -76,7 +81,7 @@ selectorToString criteria = in "containing [ " ++ selectors ++ " ] " - Invalid -> + Invalid () -> "invalid" @@ -183,7 +188,7 @@ query fn fnAll selector list = in List.filter anyDescendantsMatch elems - Invalid -> + Invalid () -> [] From 4c166fb641f41a45ab1418417d086ad795bf0e5f Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 10:16:33 +0100 Subject: [PATCH 054/123] Move helpers to top-level --- src/Test/Html/Selector/Internal.elm | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Test/Html/Selector/Internal.elm b/src/Test/Html/Selector/Internal.elm index 77fd2c34..c3727d1c 100644 --- a/src/Test/Html/Selector/Internal.elm +++ b/src/Test/Html/Selector/Internal.elm @@ -25,17 +25,6 @@ invalid = selectorToString : Selector -> String selectorToString criteria = - let - quoteString s = - "\"" ++ s ++ "\"" - - boolToString b = - if b then - "True" - - else - "False" - in case criteria of All list -> list @@ -85,6 +74,20 @@ selectorToString criteria = "invalid" +quoteString : String -> String +quoteString s = + "\"" ++ s ++ "\"" + + +boolToString : Bool -> String +boolToString b = + if b then + "True" + + else + "False" + + styleToString : { key : String, value : String } -> String styleToString { key, value } = key ++ ":" ++ value From 505a2b08ab611ff9cdc0afb8a7f0f84f468d60ee Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 10:17:19 +0100 Subject: [PATCH 055/123] Make queryAll tail-call recursive --- src/Test/Html/Selector/Internal.elm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Test/Html/Selector/Internal.elm b/src/Test/Html/Selector/Internal.elm index c3727d1c..62e2f191 100644 --- a/src/Test/Html/Selector/Internal.elm +++ b/src/Test/Html/Selector/Internal.elm @@ -114,8 +114,8 @@ queryAll selectors list = list selector :: rest -> - query ElmHtmlQuery.query queryAll selector list - |> queryAll rest + queryAll rest + (query ElmHtmlQuery.query queryAll selector list) queryAllChildren : List Selector -> List (ElmHtml msg) -> List (ElmHtml msg) From 71090f7cd1b7eda93f4a95d33e92539707eb4dd0 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 10:17:29 +0100 Subject: [PATCH 056/123] Make queryAllChildren tail-call recursive --- src/Test/Html/Selector/Internal.elm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Test/Html/Selector/Internal.elm b/src/Test/Html/Selector/Internal.elm index 62e2f191..08457275 100644 --- a/src/Test/Html/Selector/Internal.elm +++ b/src/Test/Html/Selector/Internal.elm @@ -125,8 +125,8 @@ queryAllChildren selectors list = list selector :: rest -> - query ElmHtmlQuery.queryChildren queryAllChildren selector list - |> queryAllChildren rest + queryAllChildren rest + (query ElmHtmlQuery.queryChildren queryAllChildren selector list) query : From 548b8da1e5299c3dba7a92a674d982201240f7b2 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 10:21:07 +0100 Subject: [PATCH 057/123] Rename key to name --- src/Test/Html/Internal/ElmHtml/InternalTypes.elm | 4 ++-- src/Test/Html/Selector.elm | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm index 953cf9e2..44425968 100644 --- a/src/Test/Html/Internal/ElmHtml/InternalTypes.elm +++ b/src/Test/Html/Internal/ElmHtml/InternalTypes.elm @@ -146,7 +146,7 @@ type Attribute {-| Attribute contains a string key and a string value -} type alias AttributeRecord = - { key : String + { name : String , value : String } @@ -432,7 +432,7 @@ decodeAttribute = attributeDecoder : Json.Decode.Decoder Attribute attributeDecoder = - Json.Decode.map2 (\key val -> Attribute (AttributeRecord key val)) + Json.Decode.map2 (\name val -> Attribute (AttributeRecord name val)) (Json.Decode.field "n" Json.Decode.string) (Json.Decode.field "o" Json.Decode.string) diff --git a/src/Test/Html/Selector.elm b/src/Test/Html/Selector.elm index 5cc3c76c..d6f89b22 100644 --- a/src/Test/Html/Selector.elm +++ b/src/Test/Html/Selector.elm @@ -187,14 +187,14 @@ given their semantics in `Html`. attribute : Attribute Never -> Selector attribute attr = case Inert.parseAttribute attr of - Ok (InternalTypes.Attribute { key, value }) -> - if String.toLower key == "class" then + Ok (InternalTypes.Attribute { name, value }) -> + if String.toLower name == "class" then value |> String.split " " |> Classes else - namedAttr key value + namedAttr name value Ok (InternalTypes.Property { key, value }) -> if key == "className" then From 880be540114bcd76eb773cf930cdc154d4e71303 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 10:21:46 +0100 Subject: [PATCH 058/123] Avoid recreating records --- src/Test/Html/Selector.elm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Test/Html/Selector.elm b/src/Test/Html/Selector.elm index d6f89b22..98f98ec9 100644 --- a/src/Test/Html/Selector.elm +++ b/src/Test/Html/Selector.elm @@ -187,14 +187,14 @@ given their semantics in `Html`. attribute : Attribute Never -> Selector attribute attr = case Inert.parseAttribute attr of - Ok (InternalTypes.Attribute { name, value }) -> - if String.toLower name == "class" then - value + Ok (InternalTypes.Attribute record) -> + if String.toLower record.name == "class" then + record.value |> String.split " " |> Classes else - namedAttr name value + Internal.Attribute record Ok (InternalTypes.Property { key, value }) -> if key == "className" then @@ -216,8 +216,8 @@ attribute attr = ) |> Result.withDefault Internal.invalid - Ok (InternalTypes.Style { key, value }) -> - Style { key = key, value = value } + Ok (InternalTypes.Style record) -> + Style record Ok (InternalTypes.NamespacedAttribute _) -> Internal.invalid From 7df50b335c21bb645dbd56268b014ab6cf51be2e Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 10:25:50 +0100 Subject: [PATCH 059/123] Avoid Result pipeline --- src/Test/Html/Selector.elm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Test/Html/Selector.elm b/src/Test/Html/Selector.elm index 98f98ec9..2dc5e9fc 100644 --- a/src/Test/Html/Selector.elm +++ b/src/Test/Html/Selector.elm @@ -198,11 +198,12 @@ attribute attr = Ok (InternalTypes.Property { key, value }) -> if key == "className" then - value - |> Json.Decode.decodeValue Json.Decode.string - |> Result.map (String.split " ") - |> Result.withDefault [] - |> Classes + case Json.Decode.decodeValue Json.Decode.string value of + Ok classesStr -> + Classes (String.split " " classesStr) + + Err _ -> + Classes [] else value From 2fcfaee63b5883f51cc944e2740b1d3049494a36 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 10:26:58 +0100 Subject: [PATCH 060/123] Avoid currying --- src/Test/Html/Selector.elm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Test/Html/Selector.elm b/src/Test/Html/Selector.elm index 2dc5e9fc..3529afb8 100644 --- a/src/Test/Html/Selector.elm +++ b/src/Test/Html/Selector.elm @@ -208,12 +208,12 @@ attribute attr = else value |> Json.Decode.decodeValue Json.Decode.string - |> Result.map (namedAttr key) + |> Result.map (\v -> namedAttr key v) |> orElseLazy (\() -> value |> Json.Decode.decodeValue Json.Decode.bool - |> Result.map (namedBoolAttr key) + |> Result.map (\b -> namedBoolAttr key b) ) |> Result.withDefault Internal.invalid From 688bdc839312be26c162cc26dbaa341ddd56e9f9 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 23:17:14 +0100 Subject: [PATCH 061/123] Merge Result.map and Result.andThen --- src/Test/Html/Event.elm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Test/Html/Event.elm b/src/Test/Html/Event.elm index 41a73067..03cf768a 100644 --- a/src/Test/Html/Event.elm +++ b/src/Test/Html/Event.elm @@ -140,10 +140,9 @@ when testing that an event handler is _not_ present. toResult : Event msg -> Result String msg toResult event = findHandler event - |> Result.map (Decode.map .message) |> Result.andThen (\handler -> - Decode.decodeValue handler (eventPayload event) + Decode.decodeValue (Decode.map .message handler) (eventPayload event) |> Result.mapError Decode.errorToString ) @@ -434,9 +433,8 @@ checkPreventDefault = checkEffect : (Handling msg -> Bool) -> Event msg -> Result String Bool checkEffect extractor event = findHandler event - |> Result.map (Decode.map extractor) |> Result.andThen (\handler -> - Decode.decodeValue handler (eventPayload event) + Decode.decodeValue (Decode.map extractor handler) (eventPayload event) |> Result.mapError Decode.errorToString ) From 5d7ab592a5cc913acbc363b9f335c000607fadce Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 23:23:59 +0100 Subject: [PATCH 062/123] Make traverseSelectors stop at the first error --- src/Test/Html/Query/Internal.elm | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Test/Html/Query/Internal.elm b/src/Test/Html/Query/Internal.elm index 454294ba..e997156e 100644 --- a/src/Test/Html/Query/Internal.elm +++ b/src/Test/Html/Query/Internal.elm @@ -339,7 +339,7 @@ traverse : Query msg -> Result QueryError (List (ElmHtml msg)) traverse query = case query of Query node selectorQueries -> - traverseSelectors selectorQueries [ Inert.toElmHtml node ] + traverseSelectors (List.reverse selectorQueries) [ Inert.toElmHtml node ] InternalError message -> Err (OtherInternalError message) @@ -350,10 +350,17 @@ traverse query = traverseSelectors : List SelectorQuery -> List (ElmHtml msg) -> Result QueryError (List (ElmHtml msg)) traverseSelectors selectorQueries elmHtmlList = - List.foldr - (traverseSelector >> Result.andThen) - (Ok elmHtmlList) - selectorQueries + case selectorQueries of + [] -> + Ok elmHtmlList + + selectorQuery :: rest -> + case traverseSelector selectorQuery elmHtmlList of + Ok newElmHtmlList -> + traverseSelectors rest newElmHtmlList + + (Err _) as error -> + error traverseSelector : SelectorQuery -> List (ElmHtml msg) -> Result QueryError (List (ElmHtml msg)) From e64f3257475a682d7edb0ba14b2908b470f35395 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 14 Feb 2026 23:25:31 +0100 Subject: [PATCH 063/123] Use a case expression --- src/Test/Html/Query/Internal.elm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Test/Html/Query/Internal.elm b/src/Test/Html/Query/Internal.elm index e997156e..10caea54 100644 --- a/src/Test/Html/Query/Internal.elm +++ b/src/Test/Html/Query/Internal.elm @@ -386,10 +386,12 @@ traverseSelector selectorQuery elmHtmlList = |> Ok First -> - elmHtmlList - |> List.head - |> Maybe.map (\elem -> Ok [ elem ]) - |> Maybe.withDefault (Err (NoResultsForSingle "Query.first")) + case elmHtmlList of + elem :: _ -> + Ok [ elem ] + + [] -> + Err (NoResultsForSingle "Query.first") Index index -> let From aae223084303095c960db9369612560adebcb12d Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sun, 15 Feb 2026 12:36:56 +0100 Subject: [PATCH 064/123] Add accumulator argument --- src/Simplify/Cmd.elm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index 21465d16..c669390b 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -241,13 +241,13 @@ decrementTogetherCmds length = redistributeCmds : Int -> List SimplifyCmd redistributeCmds length = let - forOffset : Int -> List SimplifyCmd - forOffset offset = + forOffset : Int -> List SimplifyCmd -> List SimplifyCmd + forOffset offset cmds = if offset >= length then - [] + cmds else - List.range 0 (length - 1 - offset) + (List.range 0 (length - 1 - offset) |> List.reverse |> List.map (\leftIndex -> @@ -259,8 +259,13 @@ redistributeCmds length = , minLength = leftIndex + offset + 1 } ) + ) + ++ cmds in - forOffset 3 ++ forOffset 2 ++ forOffset 1 + [] + |> forOffset 3 + |> forOffset 2 + |> forOffset 1 swapCmds : Int -> List SimplifyCmd From 4ba3120c5a54dae81f05d48db180f4cdd84e0d64 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sun, 15 Feb 2026 12:38:43 +0100 Subject: [PATCH 065/123] Reuse accumulator instead of appending --- src/Simplify/Cmd.elm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index c669390b..3d8775e5 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -247,10 +247,10 @@ redistributeCmds length = cmds else - (List.range 0 (length - 1 - offset) + List.range 0 (length - 1 - offset) |> List.reverse - |> List.map - (\leftIndex -> + |> List.foldr + (\leftIndex acc -> { type_ = RedistributeChoicesAndMaybeIncrement { leftIndex = leftIndex @@ -258,9 +258,9 @@ redistributeCmds length = } , minLength = leftIndex + offset + 1 } + :: acc ) - ) - ++ cmds + cmds in [] |> forOffset 3 From e3c524311878b6e04474cc20da30f56bef07bd75 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sun, 15 Feb 2026 12:39:05 +0100 Subject: [PATCH 066/123] Combine reverse and foldr into foldl --- src/Simplify/Cmd.elm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index 3d8775e5..09a1072d 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -248,8 +248,7 @@ redistributeCmds length = else List.range 0 (length - 1 - offset) - |> List.reverse - |> List.foldr + |> List.foldl (\leftIndex acc -> { type_ = RedistributeChoicesAndMaybeIncrement From 62aec2e576373e0607eb6c7cf08842015abb60f1 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sun, 15 Feb 2026 12:42:21 +0100 Subject: [PATCH 067/123] Move function to top-level --- src/Simplify/Cmd.elm | 46 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index 09a1072d..0c42ee3f 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -240,31 +240,31 @@ decrementTogetherCmds length = redistributeCmds : Int -> List SimplifyCmd redistributeCmds length = - let - forOffset : Int -> List SimplifyCmd -> List SimplifyCmd - forOffset offset cmds = - if offset >= length then - cmds + [] + |> forOffset length 3 + |> forOffset length 2 + |> forOffset length 1 - else - List.range 0 (length - 1 - offset) - |> List.foldl - (\leftIndex acc -> - { type_ = - RedistributeChoicesAndMaybeIncrement - { leftIndex = leftIndex - , rightIndex = leftIndex + offset - } - , minLength = leftIndex + offset + 1 + +forOffset : Int -> Int -> List SimplifyCmd -> List SimplifyCmd +forOffset length offset cmds = + if offset >= length then + cmds + + else + List.range 0 (length - 1 - offset) + |> List.foldl + (\leftIndex acc -> + { type_ = + RedistributeChoicesAndMaybeIncrement + { leftIndex = leftIndex + , rightIndex = leftIndex + offset } - :: acc - ) - cmds - in - [] - |> forOffset 3 - |> forOffset 2 - |> forOffset 1 + , minLength = leftIndex + offset + 1 + } + :: acc + ) + cmds swapCmds : Int -> List SimplifyCmd From 00c2e0547b37658877e6108febae6af768320e68 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sun, 15 Feb 2026 12:43:36 +0100 Subject: [PATCH 068/123] Remove redundant check --- src/Simplify/Cmd.elm | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index 0c42ee3f..d753735b 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -248,23 +248,19 @@ redistributeCmds length = forOffset : Int -> Int -> List SimplifyCmd -> List SimplifyCmd forOffset length offset cmds = - if offset >= length then - cmds - - else - List.range 0 (length - 1 - offset) - |> List.foldl - (\leftIndex acc -> - { type_ = - RedistributeChoicesAndMaybeIncrement - { leftIndex = leftIndex - , rightIndex = leftIndex + offset - } - , minLength = leftIndex + offset + 1 - } - :: acc - ) - cmds + List.range 0 (length - 1 - offset) + |> List.foldl + (\leftIndex acc -> + { type_ = + RedistributeChoicesAndMaybeIncrement + { leftIndex = leftIndex + , rightIndex = leftIndex + offset + } + , minLength = leftIndex + offset + 1 + } + :: acc + ) + cmds swapCmds : Int -> List SimplifyCmd From 4f217674dc0ab174b9c51b0e37807254f9b47f43 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sun, 15 Feb 2026 12:46:06 +0100 Subject: [PATCH 069/123] Use recursion for forOffset --- src/Simplify/Cmd.elm | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index d753735b..91c325d4 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -241,26 +241,29 @@ decrementTogetherCmds length = redistributeCmds : Int -> List SimplifyCmd redistributeCmds length = [] - |> forOffset length 3 - |> forOffset length 2 - |> forOffset length 1 - - -forOffset : Int -> Int -> List SimplifyCmd -> List SimplifyCmd -forOffset length offset cmds = - List.range 0 (length - 1 - offset) - |> List.foldl - (\leftIndex acc -> - { type_ = - RedistributeChoicesAndMaybeIncrement - { leftIndex = leftIndex - , rightIndex = leftIndex + offset - } - , minLength = leftIndex + offset + 1 - } - :: acc + |> forOffset length 3 0 + |> forOffset length 2 0 + |> forOffset length 1 0 + + +forOffset : Int -> Int -> Int -> List SimplifyCmd -> List SimplifyCmd +forOffset length offset leftIndex cmds = + if leftIndex > (length - 1 - offset) then + cmds + + else + forOffset length + offset + (leftIndex + 1) + ({ type_ = + RedistributeChoicesAndMaybeIncrement + { leftIndex = leftIndex + , rightIndex = leftIndex + offset + } + , minLength = leftIndex + offset + 1 + } + :: cmds ) - cmds swapCmds : Int -> List SimplifyCmd From ed7b19cbe63088e307706d2dcd1b388f54bbbdc5 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sun, 15 Feb 2026 12:57:24 +0100 Subject: [PATCH 070/123] Use List.foldr --- src/Simplify/Cmd.elm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index 91c325d4..e6b6034d 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -219,8 +219,8 @@ decrementTogetherCmds length = |> List.fastConcatMap (\offset -> [ 4, 2, 1 ] - |> List.map - (\by -> + |> List.foldr + (\by acc -> let rightIndex = index + offset @@ -233,7 +233,9 @@ decrementTogetherCmds length = } , minLength = rightIndex + 1 } + :: acc ) + [] ) ) From 062942bf5fa31858a1371e1d34a4a474f1e47c36 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sun, 15 Feb 2026 12:57:41 +0100 Subject: [PATCH 071/123] Reverse list order --- src/Simplify/Cmd.elm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index e6b6034d..cfdbda0e 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -218,8 +218,8 @@ decrementTogetherCmds length = List.range 1 maxOffset |> List.fastConcatMap (\offset -> - [ 4, 2, 1 ] - |> List.foldr + [ 1, 2, 4 ] + |> List.foldl (\by acc -> let rightIndex = From d3b00e65dc72710c49c7d07c4c3391b7bf468c86 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Mon, 16 Feb 2026 09:44:05 +0100 Subject: [PATCH 072/123] Use foldr instead of fastConcatMap --- src/Simplify/Cmd.elm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index cfdbda0e..adcfb132 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -216,11 +216,11 @@ decrementTogetherCmds length = (length - index - 1) in List.range 1 maxOffset - |> List.fastConcatMap - (\offset -> + |> List.foldr + (\offset acc1 -> [ 1, 2, 4 ] |> List.foldl - (\by acc -> + (\by acc2 -> let rightIndex = index + offset @@ -233,10 +233,11 @@ decrementTogetherCmds length = } , minLength = rightIndex + 1 } - :: acc + :: acc2 ) - [] + acc1 ) + [] ) From 1e4f7a6517710db9a6cc22ef1b22a05c52d30ae7 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 17 Feb 2026 16:19:44 +0100 Subject: [PATCH 073/123] Use List.foldl by creating a reverse range --- src/Simplify/Cmd.elm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index adcfb132..312309ee 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -215,8 +215,8 @@ decrementTogetherCmds length = maxOffsetLimit (length - index - 1) in - List.range 1 maxOffset - |> List.foldr + reverseRange maxOffset 1 [] + |> List.foldl (\offset acc1 -> [ 1, 2, 4 ] |> List.foldl @@ -241,6 +241,15 @@ decrementTogetherCmds length = ) +reverseRange : Int -> Int -> List Int -> List Int +reverseRange hi lo list = + if hi >= lo then + reverseRange hi (lo + 1) (lo :: list) + + else + list + + redistributeCmds : Int -> List SimplifyCmd redistributeCmds length = [] From 87fd820578cae3920c4ac9b8bd9ae0ccaef469eb Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 17 Feb 2026 16:22:54 +0100 Subject: [PATCH 074/123] Use List.foldr --- src/MicroListExtra.elm | 6 ------ src/Simplify/Cmd.elm | 7 ++++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/MicroListExtra.elm b/src/MicroListExtra.elm index d5f11eb7..8263e091 100644 --- a/src/MicroListExtra.elm +++ b/src/MicroListExtra.elm @@ -1,6 +1,5 @@ module MicroListExtra exposing ( fastConcat - , fastConcatMap , find , findMap , getAt @@ -38,11 +37,6 @@ fastConcat = List.foldr (++) [] -fastConcatMap : (a -> List b) -> List a -> List b -fastConcatMap f = - List.foldr (\e a -> f e ++ a) [] - - find : (a -> Bool) -> List a -> Maybe a find predicate list = case list of diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index 312309ee..152bfab7 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -207,8 +207,8 @@ decrementTogetherCmds length = 2 in List.range 0 (length - 2) - |> List.fastConcatMap - (\index -> + |> List.foldr + (\index acc -> let maxOffset = min @@ -237,8 +237,9 @@ decrementTogetherCmds length = ) acc1 ) - [] + acc ) + [] reverseRange : Int -> Int -> List Int -> List Int From 37a3706256954844f2d4a11d5fc3320a583b6e91 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 17 Feb 2026 16:23:26 +0100 Subject: [PATCH 075/123] Use List.foldl by creating a reverse range --- src/Simplify/Cmd.elm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Simplify/Cmd.elm b/src/Simplify/Cmd.elm index 152bfab7..ca934559 100644 --- a/src/Simplify/Cmd.elm +++ b/src/Simplify/Cmd.elm @@ -206,8 +206,8 @@ decrementTogetherCmds length = else 2 in - List.range 0 (length - 2) - |> List.foldr + reverseRange (length - 2) 0 [] + |> List.foldl (\index acc -> let maxOffset = From c15fc4b41fa9ebc3495c934c314670cbf00c08ee Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 6 Aug 2026 17:53:32 +0200 Subject: [PATCH 076/123] Flatten Simplify.runCmd --- src/Simplify.elm | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/Simplify.elm b/src/Simplify.elm index e5f83de3..d2a90a8a 100644 --- a/src/Simplify.elm +++ b/src/Simplify.elm @@ -171,34 +171,30 @@ runCmd cmd state = else state.randomRun in - let - result = - case cmd.type_ of - DeleteChunkAndMaybeDecrementPrevious chunk -> - deleteChunkAndMaybeDecrementPrevious chunk state + case cmd.type_ of + DeleteChunkAndMaybeDecrementPrevious chunk -> + deleteChunkAndMaybeDecrementPrevious chunk state - ReplaceChunkWithZero chunk -> - replaceChunkWithZero chunk state + ReplaceChunkWithZero chunk -> + replaceChunkWithZero chunk state - SortChunk chunk -> - sortChunk chunk state + SortChunk chunk -> + sortChunk chunk state - MinimizeFloat options -> - minimizeFloat options state + MinimizeFloat options -> + minimizeFloat options state - MinimizeChoice options -> - minimizeChoice options state + MinimizeChoice options -> + minimizeChoice options state - RedistributeChoicesAndMaybeIncrement options -> - redistributeChoicesAndMaybeIncrement options state + RedistributeChoicesAndMaybeIncrement options -> + redistributeChoicesAndMaybeIncrement options state - DecrementTogether options -> - decrementTogether options state + DecrementTogether options -> + decrementTogether options state - SwapChunkWithNeighbour chunk -> - swapChunkWithNeighbour chunk state - in - result + SwapChunkWithNeighbour chunk -> + swapChunkWithNeighbour chunk state {-| Tries the new RandomRun with the given fuzzer and test fn, and if the run From b6b20dfb95a65725d7df8e3c07e507f243064279 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 17 Feb 2026 17:27:08 +0100 Subject: [PATCH 077/123] Reuse constant --- src/Queue.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Queue.elm b/src/Queue.elm index 7ca2d68e..54358497 100644 --- a/src/Queue.elm +++ b/src/Queue.elm @@ -98,7 +98,7 @@ dequeue : Queue a -> ( Maybe a, Queue a ) dequeue (Queue fl rl) = case fl of [] -> - ( Nothing, Queue [] [] ) + ( Nothing, empty ) head :: tail -> ( Just head, queue tail rl ) From dbc92043768470a84127aea309debaffacc4f95e Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 17 Feb 2026 17:39:54 +0100 Subject: [PATCH 078/123] Use lambda --- src/Test/Html/Query/Internal.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Test/Html/Query/Internal.elm b/src/Test/Html/Query/Internal.elm index 10caea54..2d39b50b 100644 --- a/src/Test/Html/Query/Internal.elm +++ b/src/Test/Html/Query/Internal.elm @@ -647,7 +647,7 @@ addQueryFromHtmlLine query = [ prefixOutputLine "Query.fromHtml" , toOutputLine query |> String.split "\n" - |> List.map ((++) baseIndentation) + |> List.map (\str -> baseIndentation ++ str ++ "") |> String.join "\n" ] From 2a462680caa391e2c6f95a6c691bc5ad4412eb9b Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 17 Feb 2026 17:40:20 +0100 Subject: [PATCH 079/123] Use plain concatenation --- src/Test/Html/Query/Internal.elm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Test/Html/Query/Internal.elm b/src/Test/Html/Query/Internal.elm index 2d39b50b..313ab851 100644 --- a/src/Test/Html/Query/Internal.elm +++ b/src/Test/Html/Query/Internal.elm @@ -653,5 +653,5 @@ addQueryFromHtmlLine query = prefixOutputLine : String -> String -prefixOutputLine = - (++) "▼ " +prefixOutputLine line = + "▼ " ++ line From f8f70390e1653a854aadb256cefe8db0537f9404 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Wed, 18 Feb 2026 14:51:24 +0100 Subject: [PATCH 080/123] Apply simplifications --- src/MicroBitwiseExtra.elm | 4 +--- src/Test/Html/Query/Internal.elm | 2 +- tests/src/Runner/String/Format.elm | 14 +++++++------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/MicroBitwiseExtra.elm b/src/MicroBitwiseExtra.elm index 512eeb30..a8724d11 100644 --- a/src/MicroBitwiseExtra.elm +++ b/src/MicroBitwiseExtra.elm @@ -93,9 +93,7 @@ reverseByte b_ = reverseByteTable : Array Int reverseByteTable = -- TODO PERF `Dict Int Int` or `IntDict Int` or `List` instead? Benchmark? - List.range 0 255 - |> List.map reverseByte - |> Array.fromList + Array.initialize (255 + 1) reverseByte memoizedReverseByte : Int -> Int diff --git a/src/Test/Html/Query/Internal.elm b/src/Test/Html/Query/Internal.elm index 313ab851..48858db4 100644 --- a/src/Test/Html/Query/Internal.elm +++ b/src/Test/Html/Query/Internal.elm @@ -525,7 +525,7 @@ contains expectedDescendants query = else Expect.fail - (String.join "" + (String.concat [ "\t✗ /" , String.fromInt <| List.length missing , "\\ missing descendants: \n\n" diff --git a/tests/src/Runner/String/Format.elm b/tests/src/Runner/String/Format.elm index 447ef53f..faf25ee9 100644 --- a/tests/src/Runner/String/Format.elm +++ b/tests/src/Runner/String/Format.elm @@ -57,7 +57,7 @@ format description reason = "\nThese keys are missing: " ++ (missing |> String.join ", " |> (\d -> "[ " ++ d ++ " ]")) in - String.join "" + String.concat [ verticalBar description expected actual , "\n" , extraStr @@ -141,7 +141,7 @@ escapeUnicodeChars s = else "\\u{" ++ hexInt c ++ "}" ) - |> String.join "" + |> String.concat listDiffToString : @@ -161,7 +161,7 @@ listDiffToString index description { expected, actual } originals = , "\n" , Debug.toString originals.originalActual ] - |> String.join "" + |> String.concat ( _ :: _, [] ) -> verticalBar (description ++ " was shorter than") @@ -185,7 +185,7 @@ listDiffToString index description { expected, actual } originals = else -- We found elements that differ; fail! - String.join "" + String.concat [ verticalBar description (Debug.toString originals.originalExpected) (Debug.toString originals.originalActual) @@ -211,12 +211,12 @@ equalityToString { operation, expected, actual } = combine things = things - |> List.map (String.join "") + |> List.map String.concat |> String.join "\n" in verticalBar operation - (if String.join "" valueBelow /= String.join "" unicodeValueBelow then + (if valueBelow /= unicodeValueBelow then -- we need to show the escaped string as well combine [ valueBelow @@ -231,7 +231,7 @@ equalityToString { operation, expected, actual } = , diffArrowsBelow ] ) - (if String.join "" valueAbove /= String.join "" unicodeValueAbove then + (if valueAbove /= unicodeValueAbove then -- we need to show the escaped string as well combine [ unicodeDiffArrowsAbove From d9d8a6810bb93f5b7369a6f7af25cb995aaecdd0 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 10:10:10 +0200 Subject: [PATCH 081/123] Remove unnecessary parens --- src/Test/Fuzz.elm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index 9d0e89f6..3004b80c 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -260,7 +260,7 @@ allSufficientlyCovered c state normalizedDistributionCount = False Just expectedDistributions -> - (distributionCount + distributionCount -- Needs normalized distribution count: |> Dict.toList |> List.filterMap @@ -292,7 +292,6 @@ allSufficientlyCovered c state normalizedDistributionCount = Test.Distribution.Internal.sufficientlyCovered state.runsElapsed count (n / 100) ) ) - ) -- `Nothing` means something went wrong. We're answering the question "are all labels sufficiently covered?" and so the way to fail here is `False`. |> Maybe.withDefault False From 48da5c948379af07f442a4bc3089c49e40121401 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 10:33:40 +0200 Subject: [PATCH 082/123] Combine Maybe.traverse and List.all --- src/MicroMaybeExtra.elm | 21 --------------------- src/Test/Fuzz.elm | 38 +++++++++++++++++--------------------- 2 files changed, 17 insertions(+), 42 deletions(-) delete mode 100644 src/MicroMaybeExtra.elm diff --git a/src/MicroMaybeExtra.elm b/src/MicroMaybeExtra.elm deleted file mode 100644 index 596d1116..00000000 --- a/src/MicroMaybeExtra.elm +++ /dev/null @@ -1,21 +0,0 @@ -module MicroMaybeExtra exposing (traverse) - - -traverse : (a -> Maybe b) -> List a -> Maybe (List b) -traverse f list = - traverseHelp f list [] - - -traverseHelp : (a -> Maybe b) -> List a -> List b -> Maybe (List b) -traverseHelp f list acc = - case list of - head :: tail -> - case f head of - Just a -> - traverseHelp f tail (a :: acc) - - Nothing -> - Nothing - - [] -> - Just (List.reverse acc) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index 3004b80c..62f75013 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -6,7 +6,6 @@ import Fuzz.Internal exposing (Fuzzer) import GenResult exposing (GenResult(..)) import MicroDictExtra as Dict import MicroListExtra as List -import MicroMaybeExtra as Maybe import PRNG import Random import Simplify @@ -272,28 +271,25 @@ allSufficientlyCovered c state normalizedDistributionCount = _ -> Nothing ) - |> Maybe.traverse + |> List.all (\( labels, count ) -> - Dict.get labels expectedDistributions - |> Maybe.map (\expectedDistribution -> ( count, expectedDistribution )) - ) - |> Maybe.map - (List.all - (\( count, expectedDistribution ) -> - case expectedDistribution of - -- Zero and MoreThanZero will get checked in the Success case - Zero -> - True - - MoreThanZero -> - True - - AtLeast n -> - Test.Distribution.Internal.sufficientlyCovered state.runsElapsed count (n / 100) - ) + case Dict.get labels expectedDistributions of + Nothing -> + -- `Nothing` means something went wrong. We're answering the question "are all labels sufficiently covered?" and so the way to fail here is `False`. + False + + Just expectedDistribution -> + case expectedDistribution of + -- Zero and MoreThanZero will get checked in the Success case + Zero -> + True + + MoreThanZero -> + True + + AtLeast n -> + Test.Distribution.Internal.sufficientlyCovered state.runsElapsed count (n / 100) ) - -- `Nothing` means something went wrong. We're answering the question "are all labels sufficiently covered?" and so the way to fail here is `False`. - |> Maybe.withDefault False findBadZeroRelatedCase : LoopConstants a -> LoopState -> Maybe (Dict (List String) Int) -> Maybe DistributionFailure From 425ca21366cebee5d5b6076136359d32c64fd16b Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 10:34:36 +0200 Subject: [PATCH 083/123] Inline Dict.toList --- src/Test/Fuzz.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index 62f75013..fd15c1c9 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -261,7 +261,7 @@ allSufficientlyCovered c state normalizedDistributionCount = Just expectedDistributions -> distributionCount -- Needs normalized distribution count: - |> Dict.toList + |> Dict.foldr (\labels count list -> ( labels, count ) :: list) [] |> List.filterMap (\( labels, count ) -> case labels of From 579a729e44ee740c6b9b6e4f48c3390d563f04ad Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 10:35:19 +0200 Subject: [PATCH 084/123] Inline List.filterMap --- src/Test/Fuzz.elm | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index fd15c1c9..dc23dcec 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -262,15 +262,18 @@ allSufficientlyCovered c state normalizedDistributionCount = distributionCount -- Needs normalized distribution count: |> Dict.foldr (\labels count list -> ( labels, count ) :: list) [] - |> List.filterMap - (\( labels, count ) -> - case labels of - [ onlyLabel ] -> - Just ( onlyLabel, count ) - - _ -> - Nothing + |> List.foldr + (maybeCons + (\( labels, count ) -> + case labels of + [ onlyLabel ] -> + Just ( onlyLabel, count ) + + _ -> + Nothing + ) ) + [] |> List.all (\( labels, count ) -> case Dict.get labels expectedDistributions of @@ -292,6 +295,16 @@ allSufficientlyCovered c state normalizedDistributionCount = ) +maybeCons : (a -> Maybe b) -> a -> List b -> List b +maybeCons f mx xs = + case f mx of + Just x -> + x :: xs + + Nothing -> + xs + + findBadZeroRelatedCase : LoopConstants a -> LoopState -> Maybe (Dict (List String) Int) -> Maybe DistributionFailure findBadZeroRelatedCase c state normalizedDistributionCount = case normalizedDistributionCount of From 3a3b1736d4fdd52933bc84a6bc82b9ff6cfa9f58 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 10:39:27 +0200 Subject: [PATCH 085/123] Remove usage of maybeCons --- src/Test/Fuzz.elm | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index dc23dcec..5a0c4caf 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -263,15 +263,13 @@ allSufficientlyCovered c state normalizedDistributionCount = -- Needs normalized distribution count: |> Dict.foldr (\labels count list -> ( labels, count ) :: list) [] |> List.foldr - (maybeCons - (\( labels, count ) -> - case labels of - [ onlyLabel ] -> - Just ( onlyLabel, count ) - - _ -> - Nothing - ) + (\( labels, count ) list -> + case labels of + [ onlyLabel ] -> + ( onlyLabel, count ) :: list + + _ -> + list ) [] |> List.all @@ -295,16 +293,6 @@ allSufficientlyCovered c state normalizedDistributionCount = ) -maybeCons : (a -> Maybe b) -> a -> List b -> List b -maybeCons f mx xs = - case f mx of - Just x -> - x :: xs - - Nothing -> - xs - - findBadZeroRelatedCase : LoopConstants a -> LoopState -> Maybe (Dict (List String) Int) -> Maybe DistributionFailure findBadZeroRelatedCase c state normalizedDistributionCount = case normalizedDistributionCount of From 1855b096e09f7ac229b0db47355c6264d732c68f Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 10:40:01 +0200 Subject: [PATCH 086/123] Combine Dict.foldr and List.foldr --- src/Test/Fuzz.elm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index 5a0c4caf..fe69a7f1 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -261,9 +261,8 @@ allSufficientlyCovered c state normalizedDistributionCount = Just expectedDistributions -> distributionCount -- Needs normalized distribution count: - |> Dict.foldr (\labels count list -> ( labels, count ) :: list) [] - |> List.foldr - (\( labels, count ) list -> + |> Dict.foldr + (\labels count list -> case labels of [ onlyLabel ] -> ( onlyLabel, count ) :: list From 3b019407e88a0ed91f2e345555feca67015676f3 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 10:43:50 +0200 Subject: [PATCH 087/123] Extract isLabelSufficientlyCovered --- src/Test/Fuzz.elm | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index fe69a7f1..b950e107 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -271,25 +271,27 @@ allSufficientlyCovered c state normalizedDistributionCount = list ) [] - |> List.all - (\( labels, count ) -> - case Dict.get labels expectedDistributions of - Nothing -> - -- `Nothing` means something went wrong. We're answering the question "are all labels sufficiently covered?" and so the way to fail here is `False`. - False + |> List.all (\( labels, count ) -> isLabelSufficientlyCovered state.runsElapsed expectedDistributions labels count) - Just expectedDistribution -> - case expectedDistribution of - -- Zero and MoreThanZero will get checked in the Success case - Zero -> - True - MoreThanZero -> - True +isLabelSufficientlyCovered : Int -> Dict String ExpectedDistribution -> String -> Int -> Bool +isLabelSufficientlyCovered runsElapsed expectedDistributions labels count = + case Dict.get labels expectedDistributions of + Nothing -> + -- `Nothing` means something went wrong. We're answering the question "are all labels sufficiently covered?" and so the way to fail here is `False`. + False - AtLeast n -> - Test.Distribution.Internal.sufficientlyCovered state.runsElapsed count (n / 100) - ) + Just expectedDistribution -> + case expectedDistribution of + -- Zero and MoreThanZero will get checked in the Success case + Zero -> + True + + MoreThanZero -> + True + + AtLeast n -> + Test.Distribution.Internal.sufficientlyCovered runsElapsed count (n / 100) findBadZeroRelatedCase : LoopConstants a -> LoopState -> Maybe (Dict (List String) Int) -> Maybe DistributionFailure From 3def8ea6c7580db41e53a09b66e5db4048cf10de Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 10:49:04 +0200 Subject: [PATCH 088/123] Combine Dict.foldr and List.all --- src/Test/Fuzz.elm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index b950e107..dc34aafd 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -262,16 +262,15 @@ allSufficientlyCovered c state normalizedDistributionCount = distributionCount -- Needs normalized distribution count: |> Dict.foldr - (\labels count list -> + (\labels count soFar -> case labels of [ onlyLabel ] -> - ( onlyLabel, count ) :: list + soFar && isLabelSufficientlyCovered state.runsElapsed expectedDistributions onlyLabel count _ -> - list + soFar ) - [] - |> List.all (\( labels, count ) -> isLabelSufficientlyCovered state.runsElapsed expectedDistributions labels count) + True isLabelSufficientlyCovered : Int -> Dict String ExpectedDistribution -> String -> Int -> Bool From fe097fa7a5033fdab4126885a8ad8e6af153426f Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 10:49:47 +0200 Subject: [PATCH 089/123] Remove pipes --- src/Test/Fuzz.elm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index dc34aafd..c234b102 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -259,18 +259,18 @@ allSufficientlyCovered c state normalizedDistributionCount = False Just expectedDistributions -> - distributionCount - -- Needs normalized distribution count: - |> Dict.foldr - (\labels count soFar -> - case labels of - [ onlyLabel ] -> - soFar && isLabelSufficientlyCovered state.runsElapsed expectedDistributions onlyLabel count - - _ -> - soFar - ) - True + -- Needs normalized distribution count: + Dict.foldr + (\labels count soFar -> + case labels of + [ onlyLabel ] -> + soFar && isLabelSufficientlyCovered state.runsElapsed expectedDistributions onlyLabel count + + _ -> + soFar + ) + True + distributionCount isLabelSufficientlyCovered : Int -> Dict String ExpectedDistribution -> String -> Int -> Bool From 3ff4ce2b1f4708cadd9d4f81c664d3468a26773d Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 12:00:30 +0200 Subject: [PATCH 090/123] Avoid record update --- tests/src/Runner/String.elm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/src/Runner/String.elm b/tests/src/Runner/String.elm index 0e7d7507..1de478ca 100644 --- a/tests/src/Runner/String.elm +++ b/tests/src/Runner/String.elm @@ -92,7 +92,11 @@ fromExpectation labels expectation summary = in case Test.Runner.getFailureReason expectation of Nothing -> - { summaryWithDistribution | passed = summaryWithDistribution.passed + 1 } + { output = summaryWithDistribution.output + , failed = summaryWithDistribution.failed + , passed = summaryWithDistribution.passed + 1 + , autoFail = summaryWithDistribution.autoFail + } Just { given, description, reason } -> let @@ -114,9 +118,10 @@ fromExpectation labels expectation summary = ++ (prefix ++ indentLines message) ++ "\n" in - { summaryWithDistribution - | output = summaryWithDistribution.output ++ newOutput - , failed = summaryWithDistribution.failed + 1 + { output = summaryWithDistribution.output ++ newOutput + , failed = summaryWithDistribution.failed + 1 + , passed = summaryWithDistribution.passed + , autoFail = summaryWithDistribution.autoFail } From 0e23074cddee3c406e22248def2872e8de95639c Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 12:02:28 +0200 Subject: [PATCH 091/123] Avoid creating new summary record --- tests/src/Runner/String.elm | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/tests/src/Runner/String.elm b/tests/src/Runner/String.elm index 1de478ca..fe4dc770 100644 --- a/tests/src/Runner/String.elm +++ b/tests/src/Runner/String.elm @@ -75,27 +75,21 @@ fromExpectation labels expectation summary = |> Test.Runner.getDistributionReport |> Runner.String.Distribution.report labels - summaryWithDistribution : Summary - summaryWithDistribution = + output : String + output = case distributionReport of Nothing -> - summary + summary.output Just distribution -> - { summary - | output = - summary.output - ++ "\n\n" - ++ distribution - ++ "\n" - } + summary.output ++ "\n\n" ++ distribution ++ "\n" in case Test.Runner.getFailureReason expectation of Nothing -> - { output = summaryWithDistribution.output - , failed = summaryWithDistribution.failed - , passed = summaryWithDistribution.passed + 1 - , autoFail = summaryWithDistribution.autoFail + { output = output + , failed = summary.failed + , passed = summary.passed + 1 + , autoFail = summary.autoFail } Just { given, description, reason } -> @@ -118,10 +112,10 @@ fromExpectation labels expectation summary = ++ (prefix ++ indentLines message) ++ "\n" in - { output = summaryWithDistribution.output ++ newOutput - , failed = summaryWithDistribution.failed + 1 - , passed = summaryWithDistribution.passed - , autoFail = summaryWithDistribution.autoFail + { output = output ++ newOutput + , failed = summary.failed + 1 + , passed = summary.passed + , autoFail = summary.autoFail } From 9f97b1bc168d80a3e332066b47b86ad77d9530b3 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 12:02:52 +0200 Subject: [PATCH 092/123] Merge concatenations --- tests/src/Runner/String.elm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/src/Runner/String.elm b/tests/src/Runner/String.elm index fe4dc770..c93eac80 100644 --- a/tests/src/Runner/String.elm +++ b/tests/src/Runner/String.elm @@ -106,13 +106,15 @@ fromExpectation labels expectation summary = "Given " ++ g ++ "\n\n" newOutput = - "\n\n" + output + ++ "\n\n" ++ outputLabels labels ++ "\n" - ++ (prefix ++ indentLines message) + ++ prefix + ++ indentLines message ++ "\n" in - { output = output ++ newOutput + { output = newOutput , failed = summary.failed + 1 , passed = summary.passed , autoFail = summary.autoFail From 187a4337f7bfce80eb3fcfc2330c9f84a3e83042 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 14:18:38 +0200 Subject: [PATCH 093/123] Improve arity for fuzz2/fuzz3 --- src/Test.elm | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/src/Test.elm b/src/Test.elm index e8e85038..04c8b3c3 100644 --- a/src/Test.elm +++ b/src/Test.elm @@ -438,12 +438,8 @@ fuzz2 : -> String -> (a -> b -> Expectation) -> Test -fuzz2 fuzzA fuzzB desc = - let - fuzzer = - Fuzz.pair fuzzA fuzzB - in - (\f ( a, b ) -> f a b) >> fuzz fuzzer desc +fuzz2 fuzzA fuzzB desc getExpectation = + fuzz (Fuzz.pair fuzzA fuzzB) desc (\( a, b ) -> getExpectation a b) {-| Run a [fuzz test](#fuzz) using three random inputs. @@ -458,12 +454,8 @@ fuzz3 : -> String -> (a -> b -> c -> Expectation) -> Test -fuzz3 fuzzA fuzzB fuzzC desc = - let - fuzzer = - Fuzz.triple fuzzA fuzzB fuzzC - in - uncurry3 >> fuzz fuzzer desc +fuzz3 fuzzA fuzzB fuzzC desc getExpectation = + fuzz (Fuzz.triple fuzzA fuzzB fuzzC) desc (\( a, b, c ) -> getExpectation a b c) @@ -556,12 +548,3 @@ Currently the statistical test is tuned to allow a false positive/negative in expectDistribution : List ( ExpectedDistribution, String, a -> Bool ) -> Distribution a expectDistribution = Test.Distribution.Internal.ExpectDistribution - - - --- INTERNAL HELPERS -- - - -uncurry3 : (a -> b -> c -> d) -> ( a, b, c ) -> d -uncurry3 fn ( a, b, c ) = - fn a b c From 8d93c39ddfd16a77d092b41a599337eeaeda7dc1 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 14:20:17 +0200 Subject: [PATCH 094/123] Avoid creating record in validatedFuzzTest --- src/Test/Fuzz.elm | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index c234b102..6f1b33ce 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -62,12 +62,9 @@ validatedFuzzTest desc fuzzer getExpectation distribution = Pass { distributionReport = runResult.distributionReport } Just failure -> - { failure - | expectation = - failure.expectation - |> Test.Expectation.withDistributionReport runResult.distributionReport - } - |> formatExpectation + formatExpectation + failure.given + (Test.Expectation.withDistributionReport runResult.distributionReport failure.expectation) ) @@ -607,8 +604,8 @@ findSimplestFailure state = } -formatExpectation : Failure -> Expectation -formatExpectation { given, expectation } = +formatExpectation : Maybe String -> Expectation -> Expectation +formatExpectation given expectation = case given of Nothing -> expectation From 369945dcd998ffd0ddbb078e6638a685f1d4255c Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 14:22:26 +0200 Subject: [PATCH 095/123] Remove record for Pass --- src/Expect.elm | 2 +- src/Test/Expectation.elm | 6 +++--- src/Test/Fuzz.elm | 2 +- src/Test/Runner.elm | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Expect.elm b/src/Expect.elm index dc34ae15..4e9d6508 100644 --- a/src/Expect.elm +++ b/src/Expect.elm @@ -595,7 +595,7 @@ equalSets expected actual = -} pass : Expectation pass = - Test.Expectation.Pass { distributionReport = Test.Distribution.NoDistribution } + Test.Expectation.Pass Test.Distribution.NoDistribution {-| Fails with the given message. diff --git a/src/Test/Expectation.elm b/src/Test/Expectation.elm index 4b63253f..9946df64 100644 --- a/src/Test/Expectation.elm +++ b/src/Test/Expectation.elm @@ -10,7 +10,7 @@ import Test.Runner.Failure exposing (Reason) type Expectation - = Pass { distributionReport : DistributionReport } + = Pass DistributionReport | Fail { given : Maybe String , description : String @@ -51,5 +51,5 @@ withDistributionReport newDistributionReport expectation = Fail failure -> Fail { failure | distributionReport = newDistributionReport } - Pass pass -> - Pass { pass | distributionReport = newDistributionReport } + Pass _ -> + Pass newDistributionReport diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index 6f1b33ce..ac6172cd 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -59,7 +59,7 @@ validatedFuzzTest desc fuzzer getExpectation distribution = in case runResult.failure of Nothing -> - Pass { distributionReport = runResult.distributionReport } + Pass runResult.distributionReport Just failure -> formatExpectation diff --git a/src/Test/Runner.elm b/src/Test/Runner.elm index 3f6fb50e..2f7446c0 100644 --- a/src/Test/Runner.elm +++ b/src/Test/Runner.elm @@ -410,7 +410,7 @@ getFailureReason expectation = getDistributionReport : Expectation -> DistributionReport getDistributionReport expectation = case expectation of - Test.Expectation.Pass { distributionReport } -> + Test.Expectation.Pass distributionReport -> distributionReport Test.Expectation.Fail { distributionReport } -> From 90da6cafafe81cec66199d90f376f31abc70d78f Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 14:23:28 +0200 Subject: [PATCH 096/123] Avoid record update --- src/Test/Expectation.elm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Test/Expectation.elm b/src/Test/Expectation.elm index 9946df64..106b09d5 100644 --- a/src/Test/Expectation.elm +++ b/src/Test/Expectation.elm @@ -37,7 +37,12 @@ withGiven : String -> Expectation -> Expectation withGiven newGiven expectation = case expectation of Fail failure -> - Fail { failure | given = Just newGiven } + Fail + { given = Just newGiven + , description = failure.description + , reason = failure.reason + , distributionReport = failure.distributionReport + } Pass _ -> expectation @@ -49,7 +54,12 @@ withDistributionReport : DistributionReport -> Expectation -> Expectation withDistributionReport newDistributionReport expectation = case expectation of Fail failure -> - Fail { failure | distributionReport = newDistributionReport } + Fail + { given = failure.given + , description = failure.description + , reason = failure.reason + , distributionReport = newDistributionReport + } Pass _ -> Pass newDistributionReport From bf2d97ad796240ff0d84466237901ca4af3f6cc1 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 14:30:42 +0200 Subject: [PATCH 097/123] Avoid record update --- src/Test/Fuzz.elm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index ac6172cd..783cbea9 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -526,11 +526,11 @@ runOnce c state = in ( failure, distributionCounter ) in - { state - | failure = maybeFailure - , distributionCount = newDistributionCounter - , currentSeed = nextSeed - , runsElapsed = state.runsElapsed + 1 + { failure = maybeFailure + , distributionCount = newDistributionCounter + , currentSeed = nextSeed + , runsElapsed = state.runsElapsed + 1 + , nextPowerOfTwo = state.nextPowerOfTwo } From 589888025d7a9b739cd0558fdfe24ae1db103290 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 14:36:25 +0200 Subject: [PATCH 098/123] Pad NoDistribution to have the same shape as the other variants --- src/Expect.elm | 2 +- src/Fuzz/Internal.elm | 8 +++++++- src/Test/Distribution.elm | 2 +- src/Test/Expectation.elm | 3 ++- src/Test/Fuzz.elm | 6 +++--- tests/src/Runner/String/Distribution.elm | 2 +- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Expect.elm b/src/Expect.elm index 4e9d6508..fc958c48 100644 --- a/src/Expect.elm +++ b/src/Expect.elm @@ -595,7 +595,7 @@ equalSets expected actual = -} pass : Expectation pass = - Test.Expectation.Pass Test.Distribution.NoDistribution + Test.Expectation.Pass (Test.Distribution.NoDistribution ()) {-| Fails with the given message. diff --git a/src/Fuzz/Internal.elm b/src/Fuzz/Internal.elm index e605fa54..cb625d72 100644 --- a/src/Fuzz/Internal.elm +++ b/src/Fuzz/Internal.elm @@ -1,4 +1,4 @@ -module Fuzz.Internal exposing (Fuzzer(..), generate) +module Fuzz.Internal exposing (Fuzzer(..), generate, noDistribution) {-| This module is here just to hide the `generate` function from the end users of the library. @@ -6,6 +6,7 @@ of the library. import GenResult exposing (GenResult) import PRNG exposing (PRNG) +import Test.Distribution exposing (DistributionReport) type Fuzzer a @@ -15,3 +16,8 @@ type Fuzzer a generate : PRNG -> Fuzzer a -> GenResult a generate prng (Fuzzer fuzzer) = fuzzer prng + + +noDistribution : DistributionReport +noDistribution = + Test.Distribution.NoDistribution () diff --git a/src/Test/Distribution.elm b/src/Test/Distribution.elm index e82ed510..b2bc1bba 100644 --- a/src/Test/Distribution.elm +++ b/src/Test/Distribution.elm @@ -69,7 +69,7 @@ Get it from your `Expectation` with `Test.Runner.getDistributionReport`. -} type DistributionReport - = NoDistribution + = NoDistribution () | DistributionToReport { distributionCount : Dict (List String) Int , runsElapsed : Int diff --git a/src/Test/Expectation.elm b/src/Test/Expectation.elm index 106b09d5..88cf7997 100644 --- a/src/Test/Expectation.elm +++ b/src/Test/Expectation.elm @@ -5,6 +5,7 @@ module Test.Expectation exposing , withGiven ) +import Fuzz.Internal import Test.Distribution exposing (DistributionReport(..)) import Test.Runner.Failure exposing (Reason) @@ -27,7 +28,7 @@ fail { description, reason } = { given = Nothing , description = description , reason = reason - , distributionReport = NoDistribution + , distributionReport = Fuzz.Internal.noDistribution } diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index 783cbea9..75c24e25 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -150,7 +150,7 @@ fuzzLoop c state = { distributionReport = case state.distributionCount of Nothing -> - NoDistribution + Fuzz.Internal.noDistribution Just distributionCount -> DistributionToReport @@ -172,7 +172,7 @@ fuzzLoop c state = else case c.distribution of NoDistributionNeeded -> - { distributionReport = NoDistribution + { distributionReport = Fuzz.Internal.noDistribution , failure = Nothing } @@ -405,7 +405,7 @@ distributionFailRunResult normalizedDistributionCount failedLabel = distributionBugRunResult : RunResult distributionBugRunResult = - { distributionReport = NoDistribution + { distributionReport = Fuzz.Internal.noDistribution , failure = Just { given = Nothing diff --git a/tests/src/Runner/String/Distribution.elm b/tests/src/Runner/String/Distribution.elm index fdf9b4d5..9176145b 100644 --- a/tests/src/Runner/String/Distribution.elm +++ b/tests/src/Runner/String/Distribution.elm @@ -6,7 +6,7 @@ import Test.Distribution exposing (DistributionReport(..)) report : List String -> DistributionReport -> Maybe String report testBreadcrumbs distributionReport = case distributionReport of - NoDistribution -> + NoDistribution () -> Nothing DistributionToReport r -> From 852d24f4e3854bacd0c9f4cdf70e70d52df7f81b Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 14:39:40 +0200 Subject: [PATCH 099/123] Use boolean short-circuits in withinCompare --- src/Expect.elm | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Expect.elm b/src/Expect.elm index fc958c48..b6aa5f8b 100644 --- a/src/Expect.elm +++ b/src/Expect.elm @@ -811,12 +811,9 @@ nonNegativeToleranceError tolerance name result = withinCompare : FloatingPointTolerance -> Float -> Float -> Bool withinCompare tolerance a b = - let - withinAbsoluteTolerance = - a - absolute tolerance <= b && b <= a + absolute tolerance - - withinRelativeTolerance = - (a - abs (a * relative tolerance) <= b && b <= a + abs (a * relative tolerance)) - || (b - abs (b * relative tolerance) <= a && a <= b + abs (b * relative tolerance)) - in - (a == b) || withinAbsoluteTolerance || withinRelativeTolerance + (a == b) + -- within absolute tolerance + || (a - absolute tolerance <= b && b <= a + absolute tolerance) + -- within relative tolerance + || (a - abs (a * relative tolerance) <= b && b <= a + abs (a * relative tolerance)) + || (b - abs (b * relative tolerance) <= a && a <= b + abs (b * relative tolerance)) From 78ea5e0474608e4beafe69537e1238a65699bb14 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 14:47:03 +0200 Subject: [PATCH 100/123] Inline Test.Expectation.fail to skip an intermediate record --- src/Expect.elm | 95 +++++++++++++++++++++++++++------------- src/Test/Expectation.elm | 14 ------ src/Test/Fuzz.elm | 18 +++++--- src/Test/Internal.elm | 12 ++++- 4 files changed, 86 insertions(+), 53 deletions(-) diff --git a/src/Expect.elm b/src/Expect.elm index b6aa5f8b..7c6b9e6e 100644 --- a/src/Expect.elm +++ b/src/Expect.elm @@ -103,6 +103,7 @@ Another example is comparing values that are on either side of zero. `0.0001` is -} import Dict exposing (Dict) +import Fuzz.Internal import Set exposing (Set) import Test.Distribution import Test.Expectation @@ -392,10 +393,12 @@ ok result = pass Err _ -> - { description = "Expect.ok" - , reason = Comparison "Ok _" (Internal.toString result) - } - |> Test.Expectation.fail + Test.Expectation.Fail + { given = Nothing + , distributionReport = Fuzz.Internal.noDistribution + , description = "Expect.ok" + , reason = Comparison "Ok _" (Internal.toString result) + } {-| Passes if the @@ -433,10 +436,12 @@ err : Result a b -> Expectation err result = case result of Ok _ -> - { description = "Expect.err" - , reason = Comparison "Err _" (Internal.toString result) - } - |> Test.Expectation.fail + Test.Expectation.Fail + { given = Nothing + , distributionReport = Fuzz.Internal.noDistribution + , description = "Expect.err" + , reason = Comparison "Err _" (Internal.toString result) + } Err _ -> pass @@ -475,10 +480,12 @@ equalLists expected actual = pass else - { description = "Expect.equalLists" - , reason = ListDiff (List.map Internal.toString expected) (List.map Internal.toString actual) - } - |> Test.Expectation.fail + Test.Expectation.Fail + { given = Nothing + , distributionReport = Fuzz.Internal.noDistribution + , description = "Expect.equalLists" + , reason = ListDiff (List.map Internal.toString expected) (List.map Internal.toString actual) + } {-| Passes if the arguments are equal dicts. @@ -617,7 +624,12 @@ pass = -} fail : String -> Expectation fail str = - Test.Expectation.fail { description = str, reason = Custom } + Test.Expectation.Fail + { given = Nothing + , distributionReport = Fuzz.Internal.noDistribution + , description = str + , reason = Custom + } {-| If the given expectation fails, replace its failure message with a custom one. @@ -671,8 +683,10 @@ which argument is which: all : List (subject -> Expectation) -> subject -> Expectation all list query = if List.isEmpty list then - Test.Expectation.fail - { reason = Invalid EmptyList + Test.Expectation.Fail + { given = Nothing + , distributionReport = Fuzz.Internal.noDistribution + , reason = Invalid EmptyList , description = "Expect.all was given an empty list. You must make at least one expectation to have a valid test!" } @@ -701,16 +715,18 @@ allHelp list query = reportCollectionFailure : String -> a -> b -> List c -> List d -> Expectation reportCollectionFailure comparison expected actual missingKeys extraKeys = - { description = comparison - , reason = - { expected = Internal.toString expected - , actual = Internal.toString actual - , extra = List.map Internal.toString extraKeys - , missing = List.map Internal.toString missingKeys + Test.Expectation.Fail + { given = Nothing + , distributionReport = Fuzz.Internal.noDistribution + , description = comparison + , reason = + { expected = Internal.toString expected + , actual = Internal.toString actual + , extra = List.map Internal.toString extraKeys + , missing = List.map Internal.toString missingKeys + } + |> CollectionDiff } - |> CollectionDiff - } - |> Test.Expectation.fail {-| String arg is label, e.g. "Expect.equal". @@ -758,10 +774,12 @@ testWith makeReason label runTest expected actual = pass else - { description = label - , reason = makeReason (Internal.toString expected) (Internal.toString actual) - } - |> Test.Expectation.fail + Test.Expectation.Fail + { given = Nothing + , distributionReport = Fuzz.Internal.noDistribution + , description = label + , reason = makeReason (Internal.toString expected) (Internal.toString actual) + } @@ -797,13 +815,28 @@ relative tolerance = nonNegativeToleranceError : FloatingPointTolerance -> String -> Expectation -> Expectation nonNegativeToleranceError tolerance name result = if absolute tolerance < 0 && relative tolerance < 0 then - Test.Expectation.fail { description = "Expect." ++ name ++ " was given negative absolute and relative tolerances", reason = Custom } + Test.Expectation.Fail + { given = Nothing + , distributionReport = Fuzz.Internal.noDistribution + , description = "Expect." ++ name ++ " was given negative absolute and relative tolerances" + , reason = Custom + } else if absolute tolerance < 0 then - Test.Expectation.fail { description = "Expect." ++ name ++ " was given a negative absolute tolerance", reason = Custom } + Test.Expectation.Fail + { given = Nothing + , distributionReport = Fuzz.Internal.noDistribution + , description = "Expect." ++ name ++ " was given a negative absolute tolerance" + , reason = Custom + } else if relative tolerance < 0 then - Test.Expectation.fail { description = "Expect." ++ name ++ " was given a negative relative tolerance", reason = Custom } + Test.Expectation.Fail + { given = Nothing + , distributionReport = Fuzz.Internal.noDistribution + , description = "Expect." ++ name ++ " was given a negative relative tolerance" + , reason = Custom + } else result diff --git a/src/Test/Expectation.elm b/src/Test/Expectation.elm index 88cf7997..9ef12062 100644 --- a/src/Test/Expectation.elm +++ b/src/Test/Expectation.elm @@ -1,11 +1,9 @@ module Test.Expectation exposing ( Expectation(..) - , fail , withDistributionReport , withGiven ) -import Fuzz.Internal import Test.Distribution exposing (DistributionReport(..)) import Test.Runner.Failure exposing (Reason) @@ -20,18 +18,6 @@ type Expectation } -{-| Create a failure without specifying the given. --} -fail : { description : String, reason : Reason } -> Expectation -fail { description, reason } = - Fail - { given = Nothing - , description = description - , reason = reason - , distributionReport = Fuzz.Internal.noDistribution - } - - {-| Set the given (fuzz test input) of an expectation. -} withGiven : String -> Expectation -> Expectation diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index 75c24e25..e3621366 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -410,8 +410,10 @@ distributionBugRunResult = Just { given = Nothing , expectation = - Test.Expectation.fail - { description = "elm-test distribution collection bug" + Test.Expectation.Fail + { given = Nothing + , distributionReport = Fuzz.Internal.noDistribution + , description = "elm-test distribution collection bug" , reason = Invalid DistributionBug } } @@ -422,8 +424,10 @@ distributionInsufficientFailure : DistributionFailure -> Failure distributionInsufficientFailure failure = { given = Nothing , expectation = - Test.Expectation.fail - { description = + Test.Expectation.Fail + { given = Nothing + , distributionReport = Fuzz.Internal.noDistribution + , description = """Distribution of label "{LABEL}" was insufficient: expected: {EXPECTED_PERCENTAGE} got: {ACTUAL_PERCENTAGE}. @@ -482,8 +486,10 @@ runOnce c state = ( Just { given = Nothing , expectation = - Test.Expectation.fail - { description = reason + Test.Expectation.Fail + { given = Nothing + , distributionReport = Fuzz.Internal.noDistribution + , description = reason , reason = Invalid InvalidFuzzer } } diff --git a/src/Test/Internal.elm b/src/Test/Internal.elm index 270bc272..7e0444b4 100644 --- a/src/Test/Internal.elm +++ b/src/Test/Internal.elm @@ -1,5 +1,6 @@ module Test.Internal exposing (Test(..), blankDescriptionFailure, duplicatedName, failNow, toString) +import Fuzz.Internal import Random import Set exposing (Set) import Test.Expectation exposing (Expectation) @@ -25,9 +26,16 @@ type Test {-| Create a test that always fails for the given reason and description. -} failNow : { description : String, reason : Reason } -> Test -failNow record = +failNow { description, reason } = ElmTestVariant__UnitTest - (\() -> Test.Expectation.fail record) + (\() -> + Test.Expectation.Fail + { given = Nothing + , distributionReport = Fuzz.Internal.noDistribution + , description = description + , reason = reason + } + ) blankDescriptionFailure : Test From 90f58f0c2ebaa68a42421513a46048ec6102014d Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 14:49:59 +0200 Subject: [PATCH 101/123] Avoid record update --- src/Fuzz.elm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index 0c137d88..df8f5425 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1620,7 +1620,7 @@ rollDice maxValue diceGenerator = else Generated { value = hardcodedChoice - , prng = Hardcoded { h | unusedPart = restOfChoices } + , prng = Hardcoded { wholeRun = h.wholeRun, unusedPart = restOfChoices } } @@ -1639,7 +1639,7 @@ forcedChoice n = Random r -> Generated { value = n - , prng = Random { r | run = RandomRun.append n r.run } + , prng = Random { run = RandomRun.append n r.run, seed = r.seed } } Hardcoded h -> @@ -1661,7 +1661,7 @@ forcedChoice n = else Generated { value = n - , prng = Hardcoded { h | unusedPart = restOfChoices } + , prng = Hardcoded { wholeRun = h.wholeRun, unusedPart = restOfChoices } } From 8e82ccfb33a2b2215db9816bb4668781e2c7f66c Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 14:51:56 +0200 Subject: [PATCH 102/123] Compute weightSum more lazily --- src/Fuzz.elm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index df8f5425..8d244dd5 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1144,15 +1144,14 @@ frequencyHelp functionName fuzzers = intFrequency (List.map (Tuple.mapFirst round) nonzeroFuzzers) else - let - weightSum : Float - weightSum = - List.foldl (\( w, _ ) acc -> w + acc) 0 nonzeroFuzzers - in percentage |> andThen (\p -> let + weightSum : Float + weightSum = + List.foldl (\( w, _ ) acc -> w + acc) 0 nonzeroFuzzers + f : Float f = p * weightSum From 160507dc4158559c5cba32830632b822d74b5ee5 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 15:01:30 +0200 Subject: [PATCH 103/123] Use List.getAt --- src/Fuzz.elm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index 8d244dd5..3b612260 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1203,8 +1203,7 @@ intFrequency fuzzers = |> andThen (\i -> fuzzers - |> List.drop i - |> List.head + |> List.getAt i |> Maybe.map Tuple.second |> Maybe.withDefault (invalid "elm-test bug: intFrequency index out of range") ) From 0dc1552c9224db5b079ac13a955f7a21bac568bb Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 14:54:37 +0200 Subject: [PATCH 104/123] Compute invalid fuzzer more lazily --- src/Fuzz.elm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index 3b612260..5446fc0a 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1202,10 +1202,12 @@ intFrequency fuzzers = rollDice (weightSum - 1) (intFrequencyGenerator n (List.map Tuple.first rest)) |> andThen (\i -> - fuzzers - |> List.getAt i - |> Maybe.map Tuple.second - |> Maybe.withDefault (invalid "elm-test bug: intFrequency index out of range") + case List.getAt i fuzzers of + Just ( _, fuzzer ) -> + fuzzer + + Nothing -> + invalid "elm-test bug: intFrequency index out of range" ) [] -> From 3f3029896571ccbfc7447a1d84cf33193e4bb9bb Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 14:59:26 +0200 Subject: [PATCH 105/123] Fix typo --- src/Fuzz.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index 5446fc0a..02821284 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1818,7 +1818,7 @@ labelExamples n labels fuzzer = case Dict.get [ label ] foundExamples of Nothing -> if Dict.any (\k _ -> List.member label k) foundExamples then - -- don't show this example: all its occurences were included in combination with some other label + -- don't show this example: all its occurrences were included in combination with some other label Nothing else From e16533db5b76f3c051ed8eee2b92a6bcde4060fc Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 15:01:49 +0200 Subject: [PATCH 106/123] Move List.map --- src/Fuzz.elm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index 02821284..7616938c 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1807,11 +1807,12 @@ labelExamples n labels fuzzer = ) Dict.empty - combinations : List ( List String, a ) + combinations : List ( List String, Maybe a ) combinations = foundExamples |> Dict.filter (\k _ -> List.length k > 1) |> Dict.toList + |> List.map (\( label, example ) -> ( label, Just example )) in List.filterMap (\( label, _ ) -> @@ -1829,7 +1830,7 @@ labelExamples n labels fuzzer = Just ( [ label ], Just example ) ) labels - ++ List.map (\( label, example ) -> ( label, Just example )) combinations + ++ combinations Rejected _ -> [] From 936bd7943504c38c5bbc12c2741f492d29439a96 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 15:02:44 +0200 Subject: [PATCH 107/123] Inline Dict.filter --- src/Fuzz.elm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index 7616938c..fb9917ab 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1810,7 +1810,15 @@ labelExamples n labels fuzzer = combinations : List ( List String, Maybe a ) combinations = foundExamples - |> Dict.filter (\k _ -> List.length k > 1) + |> Dict.foldl + (\k v d -> + if List.length k > 1 then + Dict.insert k v d + + else + d + ) + Dict.empty |> Dict.toList |> List.map (\( label, example ) -> ( label, Just example )) in From 066a48926a07bc484b26af390d46e1ed501da36d Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 15:03:21 +0200 Subject: [PATCH 108/123] Inline Dict.foldr --- src/Fuzz.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index fb9917ab..090466d7 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1819,7 +1819,7 @@ labelExamples n labels fuzzer = d ) Dict.empty - |> Dict.toList + |> Dict.foldr (\key v l -> ( key, v ) :: l) [] |> List.map (\( label, example ) -> ( label, Just example )) in List.filterMap From 260fac8788eac3fdcb862d30e2690cec5294fb5f Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 15:03:57 +0200 Subject: [PATCH 109/123] Combine Dict.foldr and List.map --- src/Fuzz.elm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index 090466d7..a10a6fd1 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1819,8 +1819,7 @@ labelExamples n labels fuzzer = d ) Dict.empty - |> Dict.foldr (\key v l -> ( key, v ) :: l) [] - |> List.map (\( label, example ) -> ( label, Just example )) + |> Dict.foldr (\label example l -> ( label, Just example ) :: l) [] in List.filterMap (\( label, _ ) -> From 3351da9ded2de32ccc27f06a4e54cdc10734ebde Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 15:04:36 +0200 Subject: [PATCH 110/123] Combine Dict.foldr and Dict.foldl --- src/Fuzz.elm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index a10a6fd1..2c9f43b8 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1810,16 +1810,15 @@ labelExamples n labels fuzzer = combinations : List ( List String, Maybe a ) combinations = foundExamples - |> Dict.foldl - (\k v d -> - if List.length k > 1 then - Dict.insert k v d + |> Dict.foldr + (\label example l -> + if List.length label > 1 then + ( label, Just example ) :: l else - d + l ) - Dict.empty - |> Dict.foldr (\label example l -> ( label, Just example ) :: l) [] + [] in List.filterMap (\( label, _ ) -> From 354f32d996f319f790e3d06feb94af28d970e41b Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 15:04:43 +0200 Subject: [PATCH 111/123] Remove pipes --- src/Fuzz.elm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index 2c9f43b8..a1e04bf1 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1809,16 +1809,16 @@ labelExamples n labels fuzzer = combinations : List ( List String, Maybe a ) combinations = - foundExamples - |> Dict.foldr - (\label example l -> - if List.length label > 1 then - ( label, Just example ) :: l + Dict.foldr + (\label example l -> + if List.length label > 1 then + ( label, Just example ) :: l - else - l - ) - [] + else + l + ) + [] + foundExamples in List.filterMap (\( label, _ ) -> From 60118ef907e19305fe454148bf8adbda1f08296e Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 15:06:27 +0200 Subject: [PATCH 112/123] Avoid recreating Dict unnecessarily --- src/Fuzz.elm | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index a1e04bf1..8332f675 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1793,17 +1793,11 @@ labelExamples n labels fuzzer = if List.isEmpty categories then acc - else + else if Dict.member categories acc then acc - |> Dict.update categories - (\maybeExample -> - case maybeExample of - Nothing -> - Just item - - Just original -> - Just original - ) + + else + Dict.insert categories item acc ) Dict.empty From d29a17f9ab6b75b50cc0001d80f97b2d050f7cbf Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 15:07:00 +0200 Subject: [PATCH 113/123] Combine if branches --- src/Fuzz.elm | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index 8332f675..e23a7870 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1790,10 +1790,7 @@ labelExamples n labels fuzzer = Nothing ) in - if List.isEmpty categories then - acc - - else if Dict.member categories acc then + if List.isEmpty categories || Dict.member categories acc then acc else From b5519d7d920a169b84d6cceaec97e0dcd9efedf5 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 15:07:55 +0200 Subject: [PATCH 114/123] Avoid recreating Just --- src/Fuzz.elm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index e23a7870..cdfcb0b0 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1823,8 +1823,8 @@ labelExamples n labels fuzzer = -- show that we didn't find it (in any combination nor alone) Just ( [ label ], Nothing ) - Just example -> - Just ( [ label ], Just example ) + (Just _) as justExample -> + Just ( [ label ], justExample ) ) labels ++ combinations From 93f498150381e4dc9f26efa044cfd95af84b5fe4 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 15:09:51 +0200 Subject: [PATCH 115/123] Check for list length more optimally --- src/Fuzz.elm | 2 +- src/MicroListExtra.elm | 22 ++++++++++++++++++++++ src/Test/Fuzz.elm | 2 +- src/Test/Html/Query/Internal.elm | 3 ++- src/Test/Runner/Distribution.elm | 6 +++--- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index cdfcb0b0..2815888b 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1802,7 +1802,7 @@ labelExamples n labels fuzzer = combinations = Dict.foldr (\label example l -> - if List.length label > 1 then + if List.hasMultipleItems label then ( label, Just example ) :: l else diff --git a/src/MicroListExtra.elm b/src/MicroListExtra.elm index 8263e091..c1acb989 100644 --- a/src/MicroListExtra.elm +++ b/src/MicroListExtra.elm @@ -3,6 +3,8 @@ module MicroListExtra exposing , find , findMap , getAt + , hasMultipleItems + , isSingleton , setAt , splitWhen , transpose @@ -111,6 +113,26 @@ rowsLength listOfLists = List.length x +isSingleton : List a -> Bool +isSingleton list = + case list of + [ _ ] -> + True + + _ -> + False + + +hasMultipleItems : List a -> Bool +hasMultipleItems list = + case list of + _ :: _ :: _ -> + True + + _ -> + False + + unique : List a -> List a unique list = uniqueHelp identity [] list [] diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index e3621366..b2378757 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -551,7 +551,7 @@ includeCombinationsInBaseCounts distribution = combinations : List Int combinations = distribution - |> Dict.filter (\k _ -> List.length k > 1 && List.member single k) + |> Dict.filter (\k _ -> List.hasMultipleItems k && List.member single k) |> Dict.values in count + List.sum combinations diff --git a/src/Test/Html/Query/Internal.elm b/src/Test/Html/Query/Internal.elm index 48858db4..03b95738 100644 --- a/src/Test/Html/Query/Internal.elm +++ b/src/Test/Html/Query/Internal.elm @@ -1,6 +1,7 @@ module Test.Html.Query.Internal exposing (Multiple(..), Query(..), QueryError, SelectorQuery(..), Single(..), contains, expectAll, failWithQuery, has, hasNot, joinAsList, multipleToExpectation, prependSelector, prettyPrint, queryErrorToString, traverse, verifySingle) import Expect exposing (Expectation) +import MicroListExtra as List import Test.Html.Descendant as Descendant import Test.Html.Internal.ElmHtml.InternalTypes as InternalTypes exposing (ElmHtml(..)) import Test.Html.Internal.ElmHtml.ToString exposing (nodeToStringWithOptions) @@ -141,7 +142,7 @@ toLinesHelp expectationFailure elmHtmlList selectorQueries queryName results = ("Query.find " ++ joinAsList selectorToString selectors) |> withHtmlContext (getHtmlContext elements) in - if List.length elements == 1 then + if List.isSingleton elements then toLinesHelp expectationFailure elements diff --git a/src/Test/Runner/Distribution.elm b/src/Test/Runner/Distribution.elm index 9938e3cf..0d4cff22 100644 --- a/src/Test/Runner/Distribution.elm +++ b/src/Test/Runner/Distribution.elm @@ -33,7 +33,7 @@ formatTable { runsElapsed, distributionCount } = |> List.filter (\( labels, count ) -> not - ((List.length labels == 1) + (List.isSingleton labels && (count == 0) && isStrictSubset distributionList labels ) @@ -54,7 +54,7 @@ formatTable { runsElapsed, distributionCount } = ( baseRows, combinationsRows ) = distribution |> List.sortBy (\( _, count, _ ) -> negate count) - |> List.partition (\( labels, _, _ ) -> List.length labels <= 1) + |> List.partition (\( labels, _, _ ) -> not (List.hasMultipleItems labels)) reorderedTable = baseRows ++ combinationsRows @@ -71,7 +71,7 @@ formatTable { runsElapsed, distributionCount } = ( labels, _, _ ) = item in - List.length labels > 1 + List.hasMultipleItems labels ) |> Maybe.withDefault ( rawTable, [] ) From 863e763082afcbe6bfb73d488af4660b77f6f49e Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 15:13:01 +0200 Subject: [PATCH 116/123] Create label list only once --- src/Fuzz.elm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Fuzz.elm b/src/Fuzz.elm index 2815888b..1e1fdbd7 100644 --- a/src/Fuzz.elm +++ b/src/Fuzz.elm @@ -1813,7 +1813,12 @@ labelExamples n labels fuzzer = in List.filterMap (\( label, _ ) -> - case Dict.get [ label ] foundExamples of + let + thisLabel : List String + thisLabel = + [ label ] + in + case Dict.get thisLabel foundExamples of Nothing -> if Dict.any (\k _ -> List.member label k) foundExamples then -- don't show this example: all its occurrences were included in combination with some other label @@ -1821,10 +1826,10 @@ labelExamples n labels fuzzer = else -- show that we didn't find it (in any combination nor alone) - Just ( [ label ], Nothing ) + Just ( thisLabel, Nothing ) (Just _) as justExample -> - Just ( [ label ], justExample ) + Just ( thisLabel, justExample ) ) labels ++ combinations From d1888356c98ce6b862df78b768bd03416772cfa2 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 16:54:10 +0200 Subject: [PATCH 117/123] Inline let declaration --- src/Expect.elm | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Expect.elm b/src/Expect.elm index 7c6b9e6e..854a0f91 100644 --- a/src/Expect.elm +++ b/src/Expect.elm @@ -749,15 +749,11 @@ equateWith reason comparison b a = isFloat (Internal.toString a) || isFloat (Internal.toString b) in if usesFloats then - let - floatError = - if String.contains reason "not" then - "Do not use Expect.notEqual with floats. Use Expect.notWithin instead." + if String.contains reason "not" then + fail "Do not use Expect.notEqual with floats. Use Expect.notWithin instead." - else - "Do not use Expect.equal with floats. Use Expect.within instead." - in - fail floatError + else + fail "Do not use Expect.equal with floats. Use Expect.within instead." else testWith Equality reason comparison b a From e78b035f959af8c7f899f094a15630bf09240d3e Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 11 Aug 2026 16:54:40 +0200 Subject: [PATCH 118/123] Avoid record update --- src/RandomRun.elm | 51 ++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/src/RandomRun.elm b/src/RandomRun.elm index 32ac723b..d5fbaa12 100644 --- a/src/RandomRun.elm +++ b/src/RandomRun.elm @@ -59,18 +59,16 @@ nextChoice run = ( Just first, rest ) -> Just ( first - , { run - | length = run.length - 1 - , data = rest + , { length = run.length - 1 + , data = rest } ) append : Int -> RandomRun -> RandomRun append n run = - { run - | length = run.length + 1 - , data = Queue.enqueue (max 0 n) run.data + { length = run.length + 1 + , data = Queue.enqueue (max 0 n) run.data } @@ -104,13 +102,12 @@ deleteChunk chunk run = list = Queue.toList run.data in - { run - | length = run.length - chunk.size - , data = - (List.take chunk.startIndex list - ++ List.drop (chunk.startIndex + chunk.size) list - ) - |> Queue.fromList + { length = run.length - chunk.size + , data = + (List.take chunk.startIndex list + ++ List.drop (chunk.startIndex + chunk.size) list + ) + |> Queue.fromList } else @@ -125,14 +122,14 @@ replaceChunkWithZero chunk run = list = Queue.toList run.data in - { run - | data = - List.fastConcat - [ List.take chunk.startIndex list - , List.repeat chunk.size 0 - , List.drop (chunk.startIndex + chunk.size) list - ] - |> Queue.fromList + { length = run.length + , data = + List.fastConcat + [ List.take chunk.startIndex list + , List.repeat chunk.size 0 + , List.drop (chunk.startIndex + chunk.size) list + ] + |> Queue.fromList } else @@ -261,12 +258,12 @@ set index value run = run else - { run - | data = - run.data - |> Queue.toList - |> List.setAt index (max 0 value) run.length - |> Queue.fromList + { length = run.length + , data = + run.data + |> Queue.toList + |> List.setAt index (max 0 value) run.length + |> Queue.fromList } From 3f97e7d171f70b4f06f3fb79766f95693a81b211 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Wed, 12 Aug 2026 10:01:03 +0200 Subject: [PATCH 119/123] Speed up RandomRun comparison --- src/RandomRun.elm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/RandomRun.elm b/src/RandomRun.elm index d5fbaa12..3ba36384 100644 --- a/src/RandomRun.elm +++ b/src/RandomRun.elm @@ -267,16 +267,14 @@ set index value run = } -sortKey : RandomRun -> ( Int, List Int ) -sortKey run = - ( run.length - , toList run - ) - - compare : RandomRun -> RandomRun -> Order compare a b = - Basics.compare (sortKey a) (sortKey b) + case Basics.compare a.length b.length of + EQ -> + Basics.compare (toList a) (toList b) + + order -> + order toList : RandomRun -> List Int From 9b917278e9caf254d66e8ff2e5cc4a4daed53eab Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Wed, 12 Aug 2026 10:04:08 +0200 Subject: [PATCH 120/123] Avoid allocating a Tuple in nextChoice when returning Nothing --- src/Queue.elm | 10 +++++----- src/RandomRun.elm | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Queue.elm b/src/Queue.elm index 54358497..9b855ffc 100644 --- a/src/Queue.elm +++ b/src/Queue.elm @@ -89,19 +89,19 @@ enqueue a (Queue fl rl) = {-| Take item from `Queue` - Queue.dequeue Queue.empty == ( Nothing, Queue.empty ) + Queue.dequeue Queue.empty == Nothing - Queue.dequeue (Queue.fromList [ 1 ]) == ( Just 1, Queue.empty ) + Queue.dequeue (Queue.fromList [ 1 ]) == Just ( 1, Queue.empty ) -} -dequeue : Queue a -> ( Maybe a, Queue a ) +dequeue : Queue a -> Maybe ( a, Queue a ) dequeue (Queue fl rl) = case fl of [] -> - ( Nothing, empty ) + Nothing head :: tail -> - ( Just head, queue tail rl ) + Just ( head, queue tail rl ) diff --git a/src/RandomRun.elm b/src/RandomRun.elm index 3ba36384..b146481e 100644 --- a/src/RandomRun.elm +++ b/src/RandomRun.elm @@ -53,10 +53,10 @@ isEmpty run = nextChoice : RandomRun -> Maybe ( Int, RandomRun ) nextChoice run = case Queue.dequeue run.data of - ( Nothing, _ ) -> + Nothing -> Nothing - ( Just first, rest ) -> + Just ( first, rest ) -> Just ( first , { length = run.length - 1 From a5a6f6b2fa694cc20fcccaa9826f08615031084a Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Wed, 12 Aug 2026 11:01:52 +0200 Subject: [PATCH 121/123] Combine Dict.values and List.sum --- src/Test/Fuzz.elm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index b2378757..39d70c19 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -547,14 +547,9 @@ includeCombinationsInBaseCounts distribution = (\labels count -> case labels of [ single ] -> - let - combinations : List Int - combinations = - distribution - |> Dict.filter (\k _ -> List.hasMultipleItems k && List.member single k) - |> Dict.values - in - count + List.sum combinations + distribution + |> Dict.filter (\k _ -> List.hasMultipleItems k && List.member single k) + |> Dict.foldr (\_ value sum -> value + sum) count _ -> count From e1e81f562f91e6f90cd30b9b66854905d47c5b9e Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Wed, 12 Aug 2026 11:02:23 +0200 Subject: [PATCH 122/123] Combine Dict.filter and Dict.foldr --- src/Test/Fuzz.elm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index 39d70c19..b39a82c2 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -548,8 +548,15 @@ includeCombinationsInBaseCounts distribution = case labels of [ single ] -> distribution - |> Dict.filter (\k _ -> List.hasMultipleItems k && List.member single k) - |> Dict.foldr (\_ value sum -> value + sum) count + |> Dict.foldr + (\k value sum -> + if List.hasMultipleItems k && List.member single k then + value + sum + + else + sum + ) + count _ -> count From 2f097717a7b714fa5a04fff9ca41348ccdbfc011 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Wed, 12 Aug 2026 11:02:31 +0200 Subject: [PATCH 123/123] Remove pipes --- src/Test/Fuzz.elm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Test/Fuzz.elm b/src/Test/Fuzz.elm index b39a82c2..a568b7f2 100644 --- a/src/Test/Fuzz.elm +++ b/src/Test/Fuzz.elm @@ -547,16 +547,16 @@ includeCombinationsInBaseCounts distribution = (\labels count -> case labels of [ single ] -> - distribution - |> Dict.foldr - (\k value sum -> - if List.hasMultipleItems k && List.member single k then - value + sum - - else - sum - ) - count + Dict.foldr + (\k value sum -> + if List.hasMultipleItems k && List.member single k then + value + sum + + else + sum + ) + count + distribution _ -> count