From 86af204f11b193c8ce6634cfdbc78217a34b570a Mon Sep 17 00:00:00 2001 From: John Ky Date: Sun, 30 Jun 2019 22:07:45 +1000 Subject: [PATCH] Remove unnecessary tests --- hw-json.cabal | 25 +------ .../Data/Json/Standard/CorpusSpec.hs | 57 ---------------- .../Standard/Cursor/BalancedParensSpec.hs | 54 --------------- .../Json/Standard/Cursor/InterestBitsSpec.hs | 67 ------------------- .../Standard/Cursor/Internal/BlankSpec.hs | 51 -------------- 5 files changed, 3 insertions(+), 251 deletions(-) delete mode 100644 test/HaskellWorks/Data/Json/Standard/CorpusSpec.hs delete mode 100644 test/HaskellWorks/Data/Json/Standard/Cursor/BalancedParensSpec.hs delete mode 100644 test/HaskellWorks/Data/Json/Standard/Cursor/InterestBitsSpec.hs delete mode 100644 test/HaskellWorks/Data/Json/Standard/Cursor/Internal/BlankSpec.hs diff --git a/hw-json.cabal b/hw-json.cabal index 51912b1..38ddf42 100644 --- a/hw-json.cabal +++ b/hw-json.cabal @@ -150,24 +150,6 @@ library , HaskellWorks.Data.Json.Simple.Cursor.SemiIndex , HaskellWorks.Data.Json.Simple.Cursor.Internal.IbBp , HaskellWorks.Data.Json.Simple.Cursor.Internal.ToIbBp - , HaskellWorks.Data.Json.Standard.Cursor - , HaskellWorks.Data.Json.Standard.Cursor.Fast - , HaskellWorks.Data.Json.Standard.Cursor.Generic - , HaskellWorks.Data.Json.Standard.Cursor.Index - , HaskellWorks.Data.Json.Standard.Cursor.Internal.Blank - , HaskellWorks.Data.Json.Standard.Cursor.Internal.BlankedJson - , HaskellWorks.Data.Json.Standard.Cursor.Internal.IbBp - , HaskellWorks.Data.Json.Standard.Cursor.Internal.MakeIndex - , HaskellWorks.Data.Json.Standard.Cursor.Internal.StateMachine - , HaskellWorks.Data.Json.Standard.Cursor.Internal.ToBalancedParens64 - , HaskellWorks.Data.Json.Standard.Cursor.Internal.ToInterestBits64 - , HaskellWorks.Data.Json.Standard.Cursor.Internal.Word8 - , HaskellWorks.Data.Json.Standard.Cursor.Load.Cursor - , HaskellWorks.Data.Json.Standard.Cursor.Load.Raw - , HaskellWorks.Data.Json.Standard.Cursor.SemiIndex - , HaskellWorks.Data.Json.Standard.Cursor.Slow - , HaskellWorks.Data.Json.Standard.Cursor.Specific - , HaskellWorks.Data.Json.Standard.Cursor.Type executable hw-json import: base, config @@ -176,6 +158,7 @@ executable hw-json , generic-lens , hw-balancedparens , hw-json-simd + , hw-json-standard-cursor , hw-mquery , hw-prim , hw-rankselect @@ -206,6 +189,7 @@ test-suite hw-json-test , hw-balancedparens , hw-bits , hw-hspec-hedgehog + , hw-json-standard-cursor , hw-prim , hw-rankselect , hw-rankselect-base @@ -219,10 +203,6 @@ test-suite hw-json-test build-tools: hspec-discover other-modules: HaskellWorks.Data.Json.Simple.CursorSpec - HaskellWorks.Data.Json.Standard.CorpusSpec - HaskellWorks.Data.Json.Standard.Cursor.BalancedParensSpec - HaskellWorks.Data.Json.Standard.Cursor.InterestBitsSpec - HaskellWorks.Data.Json.Standard.Cursor.Internal.BlankSpec HaskellWorks.Data.Json.Standard.CursorSpec HaskellWorks.Data.Json.Standard.GenCursorTest HaskellWorks.Data.Json.Token.TokenizeSpec @@ -235,6 +215,7 @@ benchmark bench , bytestring , criterion , directory + , hw-json-standard-cursor , mmap , semigroups type: exitcode-stdio-1.0 diff --git a/test/HaskellWorks/Data/Json/Standard/CorpusSpec.hs b/test/HaskellWorks/Data/Json/Standard/CorpusSpec.hs deleted file mode 100644 index 47e737d..0000000 --- a/test/HaskellWorks/Data/Json/Standard/CorpusSpec.hs +++ /dev/null @@ -1,57 +0,0 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE ExplicitForAll #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE InstanceSigs #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE NoMonomorphismRestriction #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE ScopedTypeVariables #-} - -{-# OPTIONS_GHC -fno-warn-missing-signatures #-} - -module HaskellWorks.Data.Json.Standard.CorpusSpec(spec) where - -import Control.Monad.IO.Class -import HaskellWorks.Data.BalancedParens.Simple -import HaskellWorks.Data.Bits.FromBitTextByteString -import HaskellWorks.Data.Json.Standard.Cursor.Generic -import HaskellWorks.Hspec.Hedgehog -import Hedgehog -import Test.Hspec - -import qualified Data.ByteString as BS -import qualified HaskellWorks.Data.Json.Standard.Cursor.Slow as SLOW - -{-# ANN module ("HLint: ignore Redundant do" :: String) #-} -{-# ANN module ("HLint: ignore Reduce duplication" :: String) #-} -{-# ANN module ("HLint: ignore Redundant bracket" :: String) #-} - -spec :: Spec -spec = describe "HaskellWorks.Data.Json.Corpus" $ do - it "Corpus 5000B loads properly" $ requireTest $ do - inJsonBS <- liftIO $ BS.readFile "corpus/5000B.json" - inInterestBitsBS <- liftIO $ BS.readFile "corpus/5000B.json.ib.idx" - inInterestBalancedParensBS <- liftIO $ BS.readFile "corpus/5000B.json.bp.idx" - let inInterestBits = fromBitTextByteString inInterestBitsBS - let inInterestBalancedParens = fromBitTextByteString inInterestBalancedParensBS - let !cursor = SLOW.fromByteString inJsonBS - let text = cursorText cursor - let ib = interests cursor - let SimpleBalancedParens bp = balancedParens cursor - text === inJsonBS - ib === inInterestBits - bp === inInterestBalancedParens - it "issue-0001 loads properly" $ requireTest $ do - inJsonBS <- liftIO $ BS.readFile "corpus/issue-0001.json" - inInterestBitsBS <- liftIO $ BS.readFile "corpus/issue-0001.json.ib.idx" - inInterestBalancedParensBS <- liftIO $ BS.readFile "corpus/issue-0001.json.bp.idx" - let inInterestBits = fromBitTextByteString inInterestBitsBS - let inInterestBalancedParens = fromBitTextByteString inInterestBalancedParensBS - let !cursor = SLOW.fromByteString inJsonBS - let text = cursorText cursor - let ib = interests cursor - let SimpleBalancedParens bp = balancedParens cursor - text === inJsonBS - ib === inInterestBits - bp === inInterestBalancedParens diff --git a/test/HaskellWorks/Data/Json/Standard/Cursor/BalancedParensSpec.hs b/test/HaskellWorks/Data/Json/Standard/Cursor/BalancedParensSpec.hs deleted file mode 100644 index 096df54..0000000 --- a/test/HaskellWorks/Data/Json/Standard/Cursor/BalancedParensSpec.hs +++ /dev/null @@ -1,54 +0,0 @@ -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE OverloadedStrings #-} - -module HaskellWorks.Data.Json.Standard.Cursor.BalancedParensSpec - ( spec - ) where - -import Data.String -import Data.Word -import HaskellWorks.Data.Bits.BitShow -import HaskellWorks.Data.Bits.BitShown -import HaskellWorks.Data.Json.Standard.Cursor.Internal.MakeIndex -import HaskellWorks.Hspec.Hedgehog -import Hedgehog -import Test.Hspec - -import qualified Data.ByteString as BS -import qualified Data.Vector.Storable as DVS -import qualified HaskellWorks.Data.Json.Standard.Cursor.Internal.BlankedJson as J -import qualified HaskellWorks.Data.Json.Standard.Cursor.SemiIndex as SI - -{-# ANN module ("HLint: ignore Redundant do" :: String) #-} - -balancedParensOf2 :: BS.ByteString -> DVS.Vector Word64 -balancedParensOf2 bs = let SI.SemiIndex _ bp = SI.buildSemiIndex bs in bp - -spec :: Spec -spec = describe "HaskellWorks.Data.Json.Cursor.InterestBitsSpec" $ do - it "Evaluating interest bits 2" $ requireTest $ do - bitShow (balancedParensOf2 "" ) === "" - bitShow (balancedParensOf2 " \n \r \t ") === "" - bitShow (balancedParensOf2 "1234 " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (balancedParensOf2 "1.1 " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (balancedParensOf2 "-1.1e-1 " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (balancedParensOf2 "false " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (balancedParensOf2 "true " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (balancedParensOf2 "\"hello\" " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (balancedParensOf2 "\"\\\"\" " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (balancedParensOf2 "{ " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (balancedParensOf2 "} " ) === "00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (balancedParensOf2 "[ " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (balancedParensOf2 "] " ) === "00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (balancedParensOf2 ": " ) === "" - bitShow (balancedParensOf2 ", " ) === "" - bitShow (balancedParensOf2 "{{}}" ) === "11000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (balancedParensOf2 " { { } } " ) === "11000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - it "Blanking JSON should not contain strange characters 1" $ requireTest $ do - let blankedJson = J.BlankedJson ["[ [],", "[]]"] - let bp = BitShown $ BS.concat (blankedJsonToBalancedParens (J.unBlankedJson blankedJson)) - bp === fromString "11111111 11111111 00000000 11111111 00000000 00000000" - it "Blanking JSON should not contain strange characters 2" $ requireTest $ do - let blankedJson = J.BlankedJson ["[ [],", "[]]"] - let bp = BitShown $ BS.concat ((compressWordAsBit . blankedJsonToBalancedParens) (J.unBlankedJson blankedJson)) - bp === fromString "11010000" diff --git a/test/HaskellWorks/Data/Json/Standard/Cursor/InterestBitsSpec.hs b/test/HaskellWorks/Data/Json/Standard/Cursor/InterestBitsSpec.hs deleted file mode 100644 index 6cceefd..0000000 --- a/test/HaskellWorks/Data/Json/Standard/Cursor/InterestBitsSpec.hs +++ /dev/null @@ -1,67 +0,0 @@ -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE OverloadedStrings #-} - - -module HaskellWorks.Data.Json.Standard.Cursor.InterestBitsSpec(spec) where - -import Data.String -import Data.Word -import HaskellWorks.Data.Bits.BitShow -import HaskellWorks.Data.Bits.BitShown -import HaskellWorks.Hspec.Hedgehog -import Hedgehog -import Test.Hspec - -import qualified Data.ByteString as BS -import qualified Data.Vector.Storable as DVS -import qualified HaskellWorks.Data.Json.Standard.Cursor.Internal.BlankedJson as J -import qualified HaskellWorks.Data.Json.Standard.Cursor.Internal.ToInterestBits64 as J -import qualified HaskellWorks.Data.Json.Standard.Cursor.SemiIndex as SI - -{-# ANN module ("HLint: ignore Redundant do" :: String) #-} - -interestBitsOf :: BS.ByteString -> DVS.Vector Word64 -interestBitsOf bs = J.toInterestBits64 (J.toBlankedJsonTyped bs) - -interestBitsOf2 :: BS.ByteString -> DVS.Vector Word64 -interestBitsOf2 bs = let SI.SemiIndex ib _ = SI.buildSemiIndex bs in ib - -spec :: Spec -spec = describe "HaskellWorks.Data.Json.Cursor.InterestBitsSpec" $ do - it "Evaluating interest bits" $ requireTest $ do - BitShown (interestBitsOf "" ) === fromString "" - BitShown (interestBitsOf " \n \r \t ") === fromString "00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - BitShown (interestBitsOf "1234 " ) === fromString "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - BitShown (interestBitsOf "1.1 " ) === fromString "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - BitShown (interestBitsOf "-1.1e-2 " ) === fromString "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - BitShown (interestBitsOf "false " ) === fromString "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - BitShown (interestBitsOf "true " ) === fromString "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - BitShown (interestBitsOf "\"hello\" " ) === fromString "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - BitShown (interestBitsOf "\"\\\"\" " ) === fromString "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - BitShown (interestBitsOf "{ " ) === fromString "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - BitShown (interestBitsOf "} " ) === fromString "00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - BitShown (interestBitsOf "[ " ) === fromString "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - BitShown (interestBitsOf "] " ) === fromString "00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - BitShown (interestBitsOf ": " ) === fromString "00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - BitShown (interestBitsOf ", " ) === fromString "00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - BitShown (interestBitsOf "{{}}" ) === fromString "11000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - BitShown (interestBitsOf " { { } } " ) === fromString "01010000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - it "Evaluating interest bits 2" $ requireTest $ do - bitShow (interestBitsOf2 "" ) === "" - bitShow (interestBitsOf2 " \n \r \t ") === "00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 "1234 " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 "1.1 " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 "-1.1 " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 "-1.1e-2 " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 "false " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 "true " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 "\"hello\" " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 "\"\\\"\" " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 "{ " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 "} " ) === "00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 "[ " ) === "10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 "] " ) === "00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 ": " ) === "00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 ", " ) === "00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 "{{}}" ) === "11000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" - bitShow (interestBitsOf2 " { { } } " ) === "01010000 00000000 00000000 00000000 00000000 00000000 00000000 00000000" diff --git a/test/HaskellWorks/Data/Json/Standard/Cursor/Internal/BlankSpec.hs b/test/HaskellWorks/Data/Json/Standard/Cursor/Internal/BlankSpec.hs deleted file mode 100644 index 9f9d337..0000000 --- a/test/HaskellWorks/Data/Json/Standard/Cursor/Internal/BlankSpec.hs +++ /dev/null @@ -1,51 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - -module HaskellWorks.Data.Json.Standard.Cursor.Internal.BlankSpec (spec) where - -import HaskellWorks.Data.Json.Standard.Cursor.Internal.Blank -import HaskellWorks.Hspec.Hedgehog -import Hedgehog -import Test.Hspec - -import qualified Data.ByteString as BS - -{-# ANN module ("HLint: ignore Redundant do" :: String) #-} - -whenBlankedJsonShouldBe :: BS.ByteString -> BS.ByteString -> Spec -whenBlankedJsonShouldBe original expected = do - it (show original ++ " when blanked json should be " ++ show expected) $ requireTest $ do - BS.concat (blankJson [original]) === expected - -spec :: Spec -spec = describe "HaskellWorks.Data.Json.Internal.BlankSpec" $ do - describe "Can blank json" $ do - "\"\"" `whenBlankedJsonShouldBe` "()" - "\"\\\\\"" `whenBlankedJsonShouldBe` "( )" - "\"\\\\\\\"" `whenBlankedJsonShouldBe` "( " - "\" \\\\\\\"" `whenBlankedJsonShouldBe` "( " - "\" \\n\\\\\"" `whenBlankedJsonShouldBe` "( )" - "" `whenBlankedJsonShouldBe` "" - "\"\"" `whenBlankedJsonShouldBe` "()" - "\" \"" `whenBlankedJsonShouldBe` "( )" - "\" a \"" `whenBlankedJsonShouldBe` "( )" - " \"a \" x" `whenBlankedJsonShouldBe` " ( ) x" - " \"\"\"\" " `whenBlankedJsonShouldBe` " ()() " - " [][] " `whenBlankedJsonShouldBe` " [][] " - " {}{} " `whenBlankedJsonShouldBe` " {}{} " - " \"a\"b\"c\"d" `whenBlankedJsonShouldBe` " ( )b( )d" - "" `whenBlankedJsonShouldBe` "" - "1" `whenBlankedJsonShouldBe` "1" - "11" `whenBlankedJsonShouldBe` "10" - "00" `whenBlankedJsonShouldBe` "10" - "00" `whenBlankedJsonShouldBe` "10" - "-0.12e+34" `whenBlankedJsonShouldBe` "100000000" - "10.12E-34 " `whenBlankedJsonShouldBe` "100000000 " - "10.12E-34 12" `whenBlankedJsonShouldBe` "100000000 10" - " 10.12E-34 -1" `whenBlankedJsonShouldBe` " 100000000 10" - "" `whenBlankedJsonShouldBe` "" - "a" `whenBlankedJsonShouldBe` "a" - "z" `whenBlankedJsonShouldBe` "z" - " Aaa " `whenBlankedJsonShouldBe` " A__ " - " Za def " `whenBlankedJsonShouldBe` " Z_ d__ " - "" `whenBlankedJsonShouldBe` "" - " { \"ff\": 1.0, [\"\", true], null}" `whenBlankedJsonShouldBe` " { ( ): 100, [(), t___], n___}"