forked from OSS/graphql
Compare commits
2 Commits
v1.2.0.1
...
feature/rn
Author | SHA1 | Date | |
---|---|---|---|
1b3727bc05
|
|||
2fdf04f54a
|
@ -6,6 +6,10 @@ The format is based on
|
|||||||
and this project adheres to
|
and this project adheres to
|
||||||
[Haskell Package Versioning Policy](https://pvp.haskell.org/).
|
[Haskell Package Versioning Policy](https://pvp.haskell.org/).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
### Fixed
|
||||||
|
- `gql` removes not only leading `\n` but also `\r`.
|
||||||
|
|
||||||
## [1.2.0.1] - 2023-04-25
|
## [1.2.0.1] - 2023-04-25
|
||||||
### Fixed
|
### Fixed
|
||||||
- Support hspec 2.11.
|
- Support hspec 2.11.
|
||||||
@ -508,6 +512,7 @@ and this project adheres to
|
|||||||
### Added
|
### Added
|
||||||
- Data types for the GraphQL language.
|
- Data types for the GraphQL language.
|
||||||
|
|
||||||
|
[Unreleased]: https://git.caraus.tech/OSS/graphql/compare/v1.2.0.1...master
|
||||||
[1.2.0.1]: https://git.caraus.tech/OSS/graphql/compare/v1.2.0.0...v1.2.0.1
|
[1.2.0.1]: https://git.caraus.tech/OSS/graphql/compare/v1.2.0.0...v1.2.0.1
|
||||||
[1.2.0.0]: https://git.caraus.tech/OSS/graphql/compare/v1.1.0.0...v1.2.0.0
|
[1.2.0.0]: https://git.caraus.tech/OSS/graphql/compare/v1.1.0.0...v1.2.0.0
|
||||||
[1.1.0.0]: https://git.caraus.tech/OSS/graphql/compare/v1.0.3.0...v1.1.0.0
|
[1.1.0.0]: https://git.caraus.tech/OSS/graphql/compare/v1.0.3.0...v1.1.0.0
|
||||||
|
@ -21,7 +21,8 @@ extra-source-files:
|
|||||||
CHANGELOG.md
|
CHANGELOG.md
|
||||||
README.md
|
README.md
|
||||||
tested-with:
|
tested-with:
|
||||||
GHC == 9.2.5
|
GHC == 9.2.8,
|
||||||
|
GHC == 9.6.2
|
||||||
|
|
||||||
source-repository head
|
source-repository head
|
||||||
type: git
|
type: git
|
||||||
@ -84,6 +85,7 @@ test-suite graphql-test
|
|||||||
Language.GraphQL.Execute.CoerceSpec
|
Language.GraphQL.Execute.CoerceSpec
|
||||||
Language.GraphQL.Execute.OrderedMapSpec
|
Language.GraphQL.Execute.OrderedMapSpec
|
||||||
Language.GraphQL.ExecuteSpec
|
Language.GraphQL.ExecuteSpec
|
||||||
|
Language.GraphQL.THSpec
|
||||||
Language.GraphQL.Type.OutSpec
|
Language.GraphQL.Type.OutSpec
|
||||||
Language.GraphQL.Validate.RulesSpec
|
Language.GraphQL.Validate.RulesSpec
|
||||||
Schemas.HeroSchema
|
Schemas.HeroSchema
|
||||||
|
@ -12,17 +12,26 @@ import Language.Haskell.TH (Exp(..), Lit(..))
|
|||||||
|
|
||||||
stripIndentation :: String -> String
|
stripIndentation :: String -> String
|
||||||
stripIndentation code = reverse
|
stripIndentation code = reverse
|
||||||
$ dropNewlines
|
$ dropWhile isLineBreak
|
||||||
$ reverse
|
$ reverse
|
||||||
$ unlines
|
$ unlines
|
||||||
$ indent spaces <$> lines withoutLeadingNewlines
|
$ indent spaces <$> lines' withoutLeadingNewlines
|
||||||
where
|
where
|
||||||
indent 0 xs = xs
|
indent 0 xs = xs
|
||||||
indent count (' ' : xs) = indent (count - 1) xs
|
indent count (' ' : xs) = indent (count - 1) xs
|
||||||
indent _ xs = xs
|
indent _ xs = xs
|
||||||
withoutLeadingNewlines = dropNewlines code
|
withoutLeadingNewlines = dropWhile isLineBreak code
|
||||||
dropNewlines = dropWhile (== '\n')
|
|
||||||
spaces = length $ takeWhile (== ' ') withoutLeadingNewlines
|
spaces = length $ takeWhile (== ' ') withoutLeadingNewlines
|
||||||
|
lines' "" = []
|
||||||
|
lines' string =
|
||||||
|
let (line, rest) = break isLineBreak string
|
||||||
|
reminder =
|
||||||
|
case rest of
|
||||||
|
[] -> []
|
||||||
|
'\r' : '\n' : strippedString -> lines strippedString
|
||||||
|
_ : strippedString -> lines strippedString
|
||||||
|
in line : reminder
|
||||||
|
isLineBreak = flip any ['\n', '\r'] . (==)
|
||||||
|
|
||||||
-- | Removes leading and trailing newlines. Indentation of the first line is
|
-- | Removes leading and trailing newlines. Indentation of the first line is
|
||||||
-- removed from each line of the string.
|
-- removed from each line of the string.
|
||||||
|
23
tests/Language/GraphQL/THSpec.hs
Normal file
23
tests/Language/GraphQL/THSpec.hs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{- This Source Code Form is subject to the terms of the Mozilla Public License,
|
||||||
|
v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||||
|
obtain one at https://mozilla.org/MPL/2.0/. -}
|
||||||
|
|
||||||
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
|
|
||||||
|
module Language.GraphQL.THSpec
|
||||||
|
( spec
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Language.GraphQL.TH (gql)
|
||||||
|
import Test.Hspec (Spec, describe, it, shouldBe)
|
||||||
|
|
||||||
|
spec :: Spec
|
||||||
|
spec =
|
||||||
|
describe "gql" $
|
||||||
|
it "replaces CRNL with NL" $
|
||||||
|
let expected = "line1\nline2"
|
||||||
|
actual = [gql|
|
||||||
|
line1
|
||||||
|
line2
|
||||||
|
|]
|
||||||
|
in actual `shouldBe` expected
|
Reference in New Issue
Block a user