From d87ce54312e1cedae069566a8507bbb374bcf34d Mon Sep 17 00:00:00 2001 From: Marc Scholten Date: Fri, 2 Aug 2024 13:27:41 -0400 Subject: [PATCH] Moved hsx testsuite to ihp-hsx package --- {Test => ihp-hsx/Test/IHP}/HSX/ParserSpec.hs | 10 ++-- {Test => ihp-hsx/Test/IHP}/HSX/QQSpec.hs | 8 +-- ihp-hsx/Test/Main.hs | 12 +++++ ihp-hsx/ihp-hsx.cabal | 55 +++++++++++++++++++- 4 files changed, 76 insertions(+), 9 deletions(-) rename {Test => ihp-hsx/Test/IHP}/HSX/ParserSpec.hs (93%) rename {Test => ihp-hsx/Test/IHP}/HSX/QQSpec.hs (98%) create mode 100644 ihp-hsx/Test/Main.hs diff --git a/Test/HSX/ParserSpec.hs b/ihp-hsx/Test/IHP/HSX/ParserSpec.hs similarity index 93% rename from Test/HSX/ParserSpec.hs rename to ihp-hsx/Test/IHP/HSX/ParserSpec.hs index eb6849115..11b6c1506 100644 --- a/Test/HSX/ParserSpec.hs +++ b/ihp-hsx/Test/IHP/HSX/ParserSpec.hs @@ -1,11 +1,11 @@ {-| -Module: Test.HSX.QQSpec +Module: IHP.HSX.QQSpec Copyright: (c) digitally induced GmbH, 2020 -} -module Test.HSX.ParserSpec where +module IHP.HSX.ParserSpec where import Test.Hspec -import IHP.Prelude +import Prelude import IHP.HSX.Parser import qualified Text.Megaparsec as Megaparsec import qualified Text.Megaparsec.Error as Megaparsec @@ -62,12 +62,12 @@ tests = do it "should parse spread values" do let p = parseHsx position extensions "
" -- We cannot easily construct the @VarE variables@ expression, therefore we use show here for comparison - tshow p `shouldBe` "Right (Children [Node \"div\" [SpreadAttributes (VarE variables)] [] False])" + show p `shouldBe` "Right (Children [Node \"div\" [SpreadAttributes (VarE variables)] [] False])" it "should parse spread values with a space" do -- See https://github.com/digitallyinduced/ihp/issues/1588 let p = parseHsx position extensions "
" - tshow p `shouldBe` "Right (Children [Node \"div\" [SpreadAttributes (VarE variables)] [] False])" + show p `shouldBe` "Right (Children [Node \"div\" [SpreadAttributes (VarE variables)] [] False])" it "should accept underscores in data attributes" do let p = parseHsx position extensions "
" diff --git a/Test/HSX/QQSpec.hs b/ihp-hsx/Test/IHP/HSX/QQSpec.hs similarity index 98% rename from Test/HSX/QQSpec.hs rename to ihp-hsx/Test/IHP/HSX/QQSpec.hs index 5f69648c7..9bd65c05d 100644 --- a/Test/HSX/QQSpec.hs +++ b/ihp-hsx/Test/IHP/HSX/QQSpec.hs @@ -1,15 +1,17 @@ {-| -Module: Test.HSX.QQSpec +Module: IHP.HSX.QQSpec Copyright: (c) digitally induced GmbH, 2020 -} -module Test.HSX.QQSpec where +module IHP.HSX.QQSpec where import Test.Hspec -import IHP.Prelude +import Prelude import IHP.HSX.QQ import qualified Text.Blaze.Renderer.Text as Blaze import Text.Blaze (preEscapedTextValue) +import Data.Text +tests :: SpecWith () tests = do describe "HSX" do it "should work with static html" do diff --git a/ihp-hsx/Test/Main.hs b/ihp-hsx/Test/Main.hs new file mode 100644 index 000000000..288e12321 --- /dev/null +++ b/ihp-hsx/Test/Main.hs @@ -0,0 +1,12 @@ +module Main where + +import Prelude + +import Test.Hspec +import qualified IHP.HSX.QQSpec +import qualified IHP.HSX.ParserSpec + +main :: IO () +main = hspec do + IHP.HSX.QQSpec.tests + IHP.HSX.ParserSpec.tests \ No newline at end of file diff --git a/ihp-hsx/ihp-hsx.cabal b/ihp-hsx/ihp-hsx.cabal index 0fd3ef0f0..b6973912d 100644 --- a/ihp-hsx/ihp-hsx.cabal +++ b/ihp-hsx/ihp-hsx.cabal @@ -88,4 +88,57 @@ library , IHP.HSX.ConvertibleStrings , IHP.HSX.HaskellParser , IHP.HSX.HsExpToTH - , IHP.HSX.Attribute \ No newline at end of file + , IHP.HSX.Attribute + +test-suite ihp-hsx-tests + type: exitcode-stdio-1.0 + hs-source-dirs: Test + main-is: Main.hs + other-modules: + IHP.HSX.ParserSpec + IHP.HSX.QQSpec + default-language: Haskell2010 + build-depends: + base >= 4.17.0 && < 4.20 + , ihp-hsx + , hspec + , text >= 2.0.1 && < 2.2 + , bytestring >= 0.11.3 && < 0.13 + , containers >= 0.6.6 && < 0.7 + , blaze-markup + , megaparsec + , template-haskell + default-extensions: + OverloadedStrings + , NoImplicitPrelude + , ImplicitParams + , Rank2Types + , NamedFieldPuns + , TypeSynonymInstances + , FlexibleInstances + , DisambiguateRecordFields + , DuplicateRecordFields + , OverloadedLabels + , FlexibleContexts + , DataKinds + , QuasiQuotes + , TypeFamilies + , PackageImports + , ScopedTypeVariables + , RecordWildCards + , TypeApplications + , DataKinds + , InstanceSigs + , DeriveGeneric + , MultiParamTypeClasses + , TypeOperators + , DeriveDataTypeable + , DefaultSignatures + , BangPatterns + , FunctionalDependencies + , PartialTypeSignatures + , BlockArguments + , LambdaCase + , StandaloneDeriving + , TemplateHaskell + , OverloadedRecordDot \ No newline at end of file