on master help sign in
Give unescape modules unique names so both can be used in unit tests and benchmarks
cdd1a15Adam Bergmark
Data/Aeson/Parser/Internal.hs+1−1
@@ -50,7 +50,7 @@ import qualified Data.ByteString.Unsafe as B
50import qualified Data.ByteString.Lazy as L
50import qualified Data.ByteString.Lazy as L
51import qualified Data.HashMap.Strict as H
51import qualified Data.HashMap.Strict as H
52import qualified Data.Scientific as Sci
52import qualified Data.Scientific as Sci
53−import Data.Aeson.Parser.Unescape
53+import Data.Aeson.Parser.Unescape (unescapeText)
54
54
55#if MIN_VERSION_ghc_prim(0,3,1)
55#if MIN_VERSION_ghc_prim(0,3,1)
56import GHC.Base (Int#, (==#), isTrue#, word2Int#)
56import GHC.Base (Int#, (==#), isTrue#, word2Int#)
Data/Aeson/Parser/Unescape.hsnew file+11
@@ -0,0 +1,11 @@
1+{-# LANGUAGE CPP #-}
2+module Data.Aeson.Parser.Unescape
3+ (
4+ unescapeText
5+ ) where
6+
7+#ifdef CFFI
8+import Data.Aeson.Parser.UnescapeFFI (unescapeText)
9+#else
10+import Data.Aeson.Parser.UnescapePure (unescapeText)
11+#endif
aeson.cabal+16−8
@@ -51,9 +51,11 @@ extra-source-files:
51 examples/*.cabal
51 examples/*.cabal
52 examples/*.hs
52 examples/*.hs
53 examples/Twitter/*.hs
53 examples/Twitter/*.hs
54+ ffi/Data/Aeson/Parser/*.hs
54 include/*.h
55 include/*.h
55 tests/JSONTestSuite/test_parsing/*.json
56 tests/JSONTestSuite/test_parsing/*.json
56 tests/JSONTestSuite/test_transform/*.json
57 tests/JSONTestSuite/test_transform/*.json
58+ pure/Data/Aeson/Parser/*.hs
57
59
58flag developer
60flag developer
59 description: operate in developer mode
61 description: operate in developer mode
@@ -77,6 +79,7 @@ flag cffi
77
79
78library
80library
79 default-language: Haskell2010
81 default-language: Haskell2010
82+ hs-source-dirs: .
80
83
81 exposed-modules:
84 exposed-modules:
82 Data.Aeson
85 Data.Aeson
@@ -156,18 +159,25 @@ library
156
159
157 include-dirs: include
160 include-dirs: include
158 if impl(ghcjs) || !flag(cffi)
161 if impl(ghcjs) || !flag(cffi)
159− hs-source-dirs: . pure
162+ hs-source-dirs: pure
163+ other-modules: Data.Aeson.Parser.UnescapePure
160 else
164 else
161− c-sources: cbits/unescape_string.c
165+ c-sources: cbits/unescape_string.c
162 cpp-options: -DCFFI
166 cpp-options: -DCFFI
163− hs-source-dirs: . ffi
167+ hs-source-dirs: ffi
168+ other-modules: Data.Aeson.Parser.UnescapeFFI
164
169
165test-suite tests
170test-suite tests
166 default-language: Haskell2010
171 default-language: Haskell2010
167− type: exitcode-stdio-1.0
172+ type: exitcode-stdio-1.0
168− hs-source-dirs: tests
173+ hs-source-dirs: tests ffi pure
169− main-is: Tests.hs
174+ main-is: Tests.hs
175+ c-sources: cbits/unescape_string.c
176+ ghc-options: -Wall -threaded -rtsopts
177+
170 other-modules:
178 other-modules:
179+ Data.Aeson.Parser.UnescapeFFI
180+ Data.Aeson.Parser.UnescapePure
171 DataFamilies.Properties
181 DataFamilies.Properties
172 DataFamilies.Instances
182 DataFamilies.Instances
173 DataFamilies.Encoders
183 DataFamilies.Encoders
@@ -183,8 +193,6 @@ test-suite tests
183 UnitTests
193 UnitTests
184 UnitTests.NullaryConstructors
194 UnitTests.NullaryConstructors
185
195
186− ghc-options: -Wall -threaded -rtsopts
187−
188 build-depends:
196 build-depends:
189 HUnit,
197 HUnit,
190 QuickCheck >= 2.8 && <2.9.3,
198 QuickCheck >= 2.8 && <2.9.3,
ffi/Data/Aeson/Parser/Unescape.hs → ffi/Data/Aeson/Parser/UnescapeFFI.hsrenamed+1−1
@@ -2,7 +2,7 @@
2{-# LANGUAGE MagicHash #-}
2{-# LANGUAGE MagicHash #-}
3{-# LANGUAGE UnliftedFFITypes #-}
3{-# LANGUAGE UnliftedFFITypes #-}
4
4
5−module Data.Aeson.Parser.Unescape
5+module Data.Aeson.Parser.UnescapeFFI
6 (
6 (
7 unescapeText
7 unescapeText
8 ) where
8 ) where
pure/Data/Aeson/Parser/Unescape.hs → pure/Data/Aeson/Parser/UnescapePure.hsrenamed+1−1
@@ -1,4 +1,4 @@
1−module Data.Aeson.Parser.Unescape
1+module Data.Aeson.Parser.UnescapePure
2 (
2 (
3 unescapeText
3 unescapeText
4 ) where
4 ) where
tests/UnitTests.hs+4
@@ -54,6 +54,10 @@ import qualified Data.Text.Lazy.Encoding as TLE
54import qualified ErrorMessages
54import qualified ErrorMessages
55import qualified SerializationFormatSpec
55import qualified SerializationFormatSpec
56
56
57+-- Asserts that we can use both modules at once in the test suite.
58+import Data.Aeson.Parser.UnescapeFFI ()
59+import Data.Aeson.Parser.UnescapePure ()
60+
57tests :: Test
61tests :: Test
58tests = testGroup "unit" [
62tests = testGroup "unit" [
59 testGroup "SerializationFormatSpec" SerializationFormatSpec.tests
63 testGroup "SerializationFormatSpec" SerializationFormatSpec.tests