diff --git a/src/Internal/Tools/Grammar.elm b/src/Internal/Tools/Grammar.elm deleted file mode 100644 index 85db0d4..0000000 --- a/src/Internal/Tools/Grammar.elm +++ /dev/null @@ -1,74 +0,0 @@ -module Internal.Tools.Grammar exposing (..) - -{-| - - -# Identifier Grammar - -The specification defines -[some identifiers](https://spec.matrix.org/v1.9/appendices/#identifier-grammar) -to use the Common Namespaced Identifier Grammar. This is a common grammar -intended for non-user-visible identifiers, with a defined mechanism for -implementations to create new identifiers. - -This module documents those identifiers, allowing the Elm SDK to use them. - --} - -import Parser as P exposing (Parser) - - -{-| Parse an IPv6 address --} -ipv6addressParser : Parser String -ipv6addressParser = - P.chompWhile validIPv6Char - |> P.getChompedString - |> P.andThen - (\out -> - if String.length out > 45 then - P.problem "an ipv6 address has no more than 45 digits" - - else if String.length out < 2 then - P.problem "an ipv6 address has at least 2 digits" - - else - -- TODO: ipv6 has more specific rules - -- https://datatracker.ietf.org/doc/html/rfc3513#section-2.2 - P.succeed out - ) - - -{-| Parse a port value --} -portParser : Parser Int -portParser = - P.chompWhile Char.isDigit - |> P.getChompedString - |> P.andThen - (\out -> - if String.length out > 5 then - P.problem "a port has no more than 5 digits" - - else if String.length out < 1 then - P.problem "a port has at least 1 digit" - - else - case String.toInt out of - Nothing -> - P.problem "Expected port int" - - Just i -> - P.succeed i - ) - - -{-| Check whether a char is a valid IPv6char --} -validIPv6char : Char -> Bool - - -validIPv6Char c = - "0123456789ABCDEFabcdef:." - |> String.toList - |> List.member c diff --git a/tests/Test/Values/Server.elm b/tests/Test/Values/Server.elm deleted file mode 100644 index 519f4e2..0000000 --- a/tests/Test/Values/Server.elm +++ /dev/null @@ -1,127 +0,0 @@ -module Test.Values.Server exposing (..) - -import Test exposing (..) -import Fuzz exposing (Fuzzer) -import Expect - -digits : String -digits = "0123456789" - -alpha : String -alpha = "abcdefghijklmnopqrstuvwxyz" - -hex : String -hex = "0123456789abcdef" - -dns : String -dns = - digits ++ alpha ++ (String.toUpper alpha) ++ "-." - -dnsCharFuzzer : Fuzzer Char -dnsCharFuzzer = - dns - |> String.toList - |> Fuzz.oneOfValues - -dnsNameFuzzer : Fuzzer String -dnsNameFuzzer = - dnsCharFuzzer - |> Fuzz.listOfLengthBetween 1 255 - |> Fuzz.map String.fromList - -byteNumFuzzer : Fuzzer String -byteNumFuzzer = - Fuzz.intRange 0 255 - |> Fuzz.map String.fromInt - -portFuzzer : Fuzzer String -portFuzzer = - Fuzz.intRange 0 (2^16 - 1) - |> Fuzz.map String.fromInt - -ipv4Fuzzer : Fuzzer String -ipv4Fuzzer = - Fuzz.map4 - (\a b c d -> - [ a, b, c, d ] - |> List.intersperse "." - |> String.concat - ) - byteNumFuzzer - byteNumFuzzer - byteNumFuzzer - byteNumFuzzer - -ipv6CharFuzzer : Fuzzer Char -ipv6CharFuzzer = - hex - |> String.toList - |> Fuzz.oneOfValues - -ipv6PartFuzzer : Fuzzer String -ipv6PartFuzzer = - ipv6CharFuzzer - |> Fuzz.listOfLengthBetween 1 4 - |> Fuzz.map String.fromList - -ipv6Sides : Fuzzer (Int, Int) -ipv6Sides = - Fuzz.intRange 0 7 - |> Fuzz.andThen - (\a -> - Fuzz.intRange 0 (7-a) - |> Fuzz.map (\b -> (a, b)) - ) - -ipv6Fuzzer : Fuzzer String -ipv6Fuzzer = - Fuzz.oneOf - [ ipv6PartFuzzer - |> Fuzz.listOfLength 8 - |> Fuzz.map (List.intersperse ":") - |> Fuzz.map String.concat - , ipv6Sides - |> Fuzz.andThen - (\(a, b) -> - Fuzz.pair - (Fuzz.listOfLength a ipv6PartFuzzer) - (Fuzz.listOfLength b ipv6PartFuzzer) - ) - |> Fuzz.map - (\(la, lb) -> - [ List.intersperse ":" la - , [ "::" ] - , List.intersperse ":" lb - ] - |> List.concat - |> String.concat - ) - ] - -hostnameFuzzer : Fuzzer String -hostnameFuzzer = - Fuzz.oneOf - [ ipv4Fuzzer - , Fuzz.map (\ip -> "[" ++ ip ++ "]") ipv6Fuzzer - , dnsNameFuzzer - ] - -serverNameFuzzer : Fuzzer String -serverNameFuzzer = - Fuzz.map2 (++) - hostnameFuzzer - ( Fuzz.oneOf - [ Fuzz.constant "" - , Fuzz.map (\p -> ":" ++ p) portFuzzer - ] - ) - |> Fuzz.map (Debug.log "Server") - -suite : Test -suite = - describe "Server name tester" - [ fuzz serverNameFuzzer "IPv6 test" - (\_ -> - Expect.pass - ) - ] \ No newline at end of file