From d29146a7be4d43d6746f53df92f2b6fbfd9f109f Mon Sep 17 00:00:00 2001 From: Marco Zocca Date: Sun, 9 Oct 2022 16:13:55 +0200 Subject: [PATCH 1/2] extract integration tests from test suite --- .../Integration/HaskellToScalaSpec.hs | 0 .../Integration/RoundTripThroughFlatcSpec.hs | 0 integration/Spec.hs | 1 + package.yaml | 25 ++++++++++++++++++- {test => test-common}/Examples.hs | 0 {test => test-common}/Examples/Generated.hs | 0 {test => test-common}/TestImports.hs | 0 7 files changed, 25 insertions(+), 1 deletion(-) rename {test => integration}/FlatBuffers/Integration/HaskellToScalaSpec.hs (100%) rename {test => integration}/FlatBuffers/Integration/RoundTripThroughFlatcSpec.hs (100%) create mode 100644 integration/Spec.hs rename {test => test-common}/Examples.hs (100%) rename {test => test-common}/Examples/Generated.hs (100%) rename {test => test-common}/TestImports.hs (100%) diff --git a/test/FlatBuffers/Integration/HaskellToScalaSpec.hs b/integration/FlatBuffers/Integration/HaskellToScalaSpec.hs similarity index 100% rename from test/FlatBuffers/Integration/HaskellToScalaSpec.hs rename to integration/FlatBuffers/Integration/HaskellToScalaSpec.hs diff --git a/test/FlatBuffers/Integration/RoundTripThroughFlatcSpec.hs b/integration/FlatBuffers/Integration/RoundTripThroughFlatcSpec.hs similarity index 100% rename from test/FlatBuffers/Integration/RoundTripThroughFlatcSpec.hs rename to integration/FlatBuffers/Integration/RoundTripThroughFlatcSpec.hs diff --git a/integration/Spec.hs b/integration/Spec.hs new file mode 100644 index 0000000..a824f8c --- /dev/null +++ b/integration/Spec.hs @@ -0,0 +1 @@ +{-# OPTIONS_GHC -F -pgmF hspec-discover #-} diff --git a/package.yaml b/package.yaml index 0c3bd4d..e6a4108 100644 --- a/package.yaml +++ b/package.yaml @@ -55,7 +55,30 @@ library: tests: test: main: Spec.hs - source-dirs: test/ + source-dirs: + - test/ + - test-common/ + dependencies: + - flatbuffers + - hspec + - hspec-core + - hspec-expectations-pretty-diff + - HUnit + - hspec-megaparsec + - hedgehog + - hw-hspec-hedgehog + - aeson + - aeson-pretty + - raw-strings-qq + - utf8-string + - process + - th-pprint + - pretty-simple + integration: + main: Spec.hs + source-dirs: + - integration/ + - test-common/ dependencies: - flatbuffers - hspec diff --git a/test/Examples.hs b/test-common/Examples.hs similarity index 100% rename from test/Examples.hs rename to test-common/Examples.hs diff --git a/test/Examples/Generated.hs b/test-common/Examples/Generated.hs similarity index 100% rename from test/Examples/Generated.hs rename to test-common/Examples/Generated.hs diff --git a/test/TestImports.hs b/test-common/TestImports.hs similarity index 100% rename from test/TestImports.hs rename to test-common/TestImports.hs From 8ac1be9ef5c997946304d68d9e5bae2834252118 Mon Sep 17 00:00:00 2001 From: Marco Zocca Date: Sun, 9 Oct 2022 16:30:19 +0200 Subject: [PATCH 2/2] add broken test for type keyword --- test/FlatBuffers/Internal/Compiler/THSpec.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/FlatBuffers/Internal/Compiler/THSpec.hs b/test/FlatBuffers/Internal/Compiler/THSpec.hs index f554311..4eca145 100644 --- a/test/FlatBuffers/Internal/Compiler/THSpec.hs +++ b/test/FlatBuffers/Internal/Compiler/THSpec.hs @@ -78,6 +78,21 @@ spec = type_ = writeTable [] |] + describe "Haskell reserved keywords" $ do + it "type" $ + [r| table T { + type: bool; + }|] `shouldCompileTo` + [d| + data T + t :: Maybe Bool -> WriteTable T + t x = writeTable [ + optionalDef False writeBoolTableField x + ] + tType :: Table T -> Either ReadError Bool + tType = readTableFieldWithDef readBool 0 False + |] + describe "numeric fields + boolean" $ do it "normal fields" $ [r|