commit ghc-base-compat for openSUSE:Factory
Hello community,
here is the log from the commit of package ghc-base-compat for openSUSE:Factory checked in at 2016-01-28 17:23:32
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-base-compat (Old)
and /work/SRC/openSUSE:Factory/.ghc-base-compat.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-base-compat"
Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-base-compat/ghc-base-compat.changes 2015-12-24 12:16:19.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.ghc-base-compat.new/ghc-base-compat.changes 2016-01-28 17:24:29.000000000 +0100
@@ -1,0 +2,22 @@
+Wed Jan 20 08:43:57 UTC 2016 - mimi.vx@gmail.com
+
+- update to 0.9.0
+* Sync with base-4.9/GHC 8.0
+* Weakened RealFloat constraints on realPart, imagPart, conjugate, mkPolar, and cis
+ in Data.Complex.Compat
+* Backport Foreign.ForeignPtr.Safe and Foreign.Marshal.Safe
+* Generalize filterM, forever, mapAndUnzipM, zipWithM, zipWithM_, replicateM,
+ and replicateM_ in Control.Monad from Monad to Applicative
+* Backport .Unsafe.Compat modules (for Control.Monad.ST, Control.Monad.ST.Lazy,
+ Foreign.ForeignPtr, and Foreign.Marshal)
+* Backport forkFinally and forkOSWithUnmask to Control.Concurrent.Compat
+* Backport Data.Functor.Const
+* Backport modifyIORef', atomicModifyIORef' and atomicWriteIORef to Data.IORef.Compat
+* Data.Ratio.{denominator,numerator} have no Integral constraint anymore
+* Backport modifySTRef' to Data.STRef.Compat
+* Export String, lines, words, unlines, and unwords to Data.String.Compat
+* Generalize Debug.Trace.{traceM, traceShowM} from Monad to Applicative
+* Backport errorWithoutStackTrace to Prelude.Compat
+* Backport unsafeFixIO and unsafeDupablePerformIO to System.IO.Unsafe.Compat
+
+-------------------------------------------------------------------
Old:
----
base-compat-0.8.2.tar.gz
New:
----
base-compat-0.9.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ghc-base-compat.spec ++++++
--- /var/tmp/diff_new_pack.uAgpB6/_old 2016-01-28 17:24:29.000000000 +0100
+++ /var/tmp/diff_new_pack.uAgpB6/_new 2016-01-28 17:24:29.000000000 +0100
@@ -20,7 +20,7 @@
%bcond_with tests
Name: ghc-base-compat
-Version: 0.8.2
+Version: 0.9.0
Release: 0
Summary: A compatibility layer for base
Group: System/Libraries
++++++ base-compat-0.8.2.tar.gz -> base-compat-0.9.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/CHANGES.markdown new/base-compat-0.9.0/CHANGES.markdown
--- old/base-compat-0.8.2/CHANGES.markdown 2015-05-13 08:36:37.000000000 +0200
+++ new/base-compat-0.9.0/CHANGES.markdown 2016-01-15 03:45:49.000000000 +0100
@@ -1,3 +1,26 @@
+## Changes in 0.9.0
+ - Sync with `base-4.9`/GHC 8.0
+ - Weakened `RealFloat` constraints on `realPart`, `imagPart`, `conjugate`,
+ `mkPolar`, and `cis` in `Data.Complex.Compat`
+ - Backport `Foreign.ForeignPtr.Safe` and `Foreign.Marshal.Safe`
+ - Generalize `filterM`, `forever`, `mapAndUnzipM`, `zipWithM`, `zipWithM_`,
+ `replicateM`, and `replicateM_` in `Control.Monad` from `Monad` to
+ `Applicative`
+ - Backport `.Unsafe.Compat` modules (for `Control.Monad.ST`,
+ `Control.Monad.ST.Lazy`, `Foreign.ForeignPtr`, and `Foreign.Marshal`)
+ - Backport `forkFinally` and `forkOSWithUnmask` to `Control.Concurrent.Compat`
+ - Backport `Data.Functor.Const`
+ - Backport `modifyIORef'`, `atomicModifyIORef'` and `atomicWriteIORef` to
+ `Data.IORef.Compat`
+ - `Data.Ratio.{denominator,numerator}` have no `Integral` constraint anymore
+ - Backport `modifySTRef'` to `Data.STRef.Compat`
+ - Export `String`, `lines`, `words`, `unlines`, and `unwords` to
+ `Data.String.Compat`
+ - Generalize `Debug.Trace.{traceM, traceShowM}` from `Monad` to `Applicative`
+ - Backport `errorWithoutStackTrace` to `Prelude.Compat`
+ - Backport `unsafeFixIO` and `unsafeDupablePerformIO` to
+ `System.IO.Unsafe.Compat`
+
## Changes in 0.8.2
- Backport `bitDefault`, `testBitDefault`, and `popCountDefault` in
`Data.Bits.Compat` to all versions of `base`
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/LICENSE new/base-compat-0.9.0/LICENSE
--- old/base-compat-0.8.2/LICENSE 2015-05-13 08:36:37.000000000 +0200
+++ new/base-compat-0.9.0/LICENSE 2016-01-15 03:45:49.000000000 +0100
@@ -1,4 +1,4 @@
-Copyright (c) 2012-2015 Simon Hengel
... = do x <- ... @@ -40,20 +58,20 @@
/Since: 4.7.0.0/ -} -traceM :: (Monad m) => String -> m () -traceM string = trace string $ return () +traceM :: (Applicative f) => String -> f () +traceM string = trace string $ pure () {-| Like 'traceM', but uses 'show' on the argument to convert it to a 'String'.
... = do x <- ... -> traceMShow $ x +> traceShowM $ x y <- ... -> traceMShow $ x + y +> traceShowM $ x + y
/Since: 4.7.0.0/ -} -traceShowM :: (Show a, Monad m) => a -> m () +traceShowM :: (Show a, Applicative f) => a -> f () traceShowM = traceM . show #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/src/Foreign/ForeignPtr/Safe/Compat.hs new/base-compat-0.9.0/src/Foreign/ForeignPtr/Safe/Compat.hs --- old/base-compat-0.8.2/src/Foreign/ForeignPtr/Safe/Compat.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/src/Foreign/ForeignPtr/Safe/Compat.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,34 @@ +{-# LANGUAGE CPP, NoImplicitPrelude #-} +module Foreign.ForeignPtr.Safe.Compat ( + -- * Finalised data pointers + ForeignPtr + , FinalizerPtr +#if defined(__HUGS__) || defined(__GLASGOW_HASKELL__) + , FinalizerEnvPtr +#endif + -- ** Basic operations + , newForeignPtr + , newForeignPtr_ + , addForeignPtrFinalizer +#if defined(__HUGS__) || defined(__GLASGOW_HASKELL__) + , newForeignPtrEnv + , addForeignPtrFinalizerEnv +#endif + , withForeignPtr + +#ifdef __GLASGOW_HASKELL__ + , finalizeForeignPtr +#endif + + -- ** Low-level operations + , touchForeignPtr + , castForeignPtr + + -- ** Allocating managed memory + , mallocForeignPtr + , mallocForeignPtrBytes + , mallocForeignPtrArray + , mallocForeignPtrArray0 + ) where + +import Foreign.ForeignPtr diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/src/Foreign/ForeignPtr/Unsafe/Compat.hs new/base-compat-0.9.0/src/Foreign/ForeignPtr/Unsafe/Compat.hs --- old/base-compat-0.8.2/src/Foreign/ForeignPtr/Unsafe/Compat.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/src/Foreign/ForeignPtr/Unsafe/Compat.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,11 @@ +{-# LANGUAGE CPP, NoImplicitPrelude #-} +module Foreign.ForeignPtr.Unsafe.Compat ( + -- ** Unsafe low-level operations + unsafeForeignPtrToPtr +) where + +#if MIN_VERSION_base(4,6,0) +import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr) +#else +import Foreign.ForeignPtr (unsafeForeignPtrToPtr) +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/src/Foreign/Marshal/Safe/Compat.hs new/base-compat-0.9.0/src/Foreign/Marshal/Safe/Compat.hs --- old/base-compat-0.8.2/src/Foreign/Marshal/Safe/Compat.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/src/Foreign/Marshal/Safe/Compat.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,16 @@ +{-# LANGUAGE CPP, NoImplicitPrelude #-} +module Foreign.Marshal.Safe.Compat ( + -- | The module "Foreign.Marshal.Safe" re-exports the other modules in the + -- @Foreign.Marshal@ hierarchy: + module Foreign.Marshal.Alloc + , module Foreign.Marshal.Array + , module Foreign.Marshal.Error + , module Foreign.Marshal.Pool + , module Foreign.Marshal.Utils + ) where + +import Foreign.Marshal.Alloc +import Foreign.Marshal.Array +import Foreign.Marshal.Error +import Foreign.Marshal.Pool +import Foreign.Marshal.Utils diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/src/Foreign/Marshal/Unsafe/Compat.hs new/base-compat-0.9.0/src/Foreign/Marshal/Unsafe/Compat.hs --- old/base-compat-0.8.2/src/Foreign/Marshal/Unsafe/Compat.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/src/Foreign/Marshal/Unsafe/Compat.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,11 @@ +{-# LANGUAGE CPP, NoImplicitPrelude #-} +module Foreign.Marshal.Unsafe.Compat ( + -- * Unsafe functions + unsafeLocalState +) where + +#if MIN_VERSION_base(4,6,0) +import Foreign.Marshal.Unsafe (unsafeLocalState) +#else +import Foreign.Marshal (unsafeLocalState) +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/src/Prelude/Compat.hs new/base-compat-0.9.0/src/Prelude/Compat.hs --- old/base-compat-0.8.2/src/Prelude/Compat.hs 2015-05-13 08:36:37.000000000 +0200 +++ new/base-compat-0.9.0/src/Prelude/Compat.hs 2016-01-15 03:45:49.000000000 +0100 @@ -1,6 +1,6 @@ {-# LANGUAGE CPP, NoImplicitPrelude #-} module Prelude.Compat ( -#if MIN_VERSION_base(4,8,0) +#if MIN_VERSION_base(4,9,0) module Base #else either @@ -101,6 +101,7 @@ , (||) , ($) , error +, errorWithoutStackTrace , undefined , seq @@ -257,7 +258,7 @@ ) where -#if MIN_VERSION_base(4,8,0) +#if MIN_VERSION_base(4,9,0) import Prelude as Base @@ -290,9 +291,21 @@ , sum ) -import Data.Word import Data.Foldable.Compat import Data.Traversable -import Data.Monoid + +# if !(MIN_VERSION_base(4,8,0)) import Control.Applicative +import Data.Monoid +import Data.Word +# endif +#endif + +#if !(MIN_VERSION_base(4,9,0)) +-- | A variant of 'error' that does not produce a stack trace. +-- +-- /Since: 4.9.0.0/ +errorWithoutStackTrace :: [Char] -> a +errorWithoutStackTrace s = error s +{-# NOINLINE errorWithoutStackTrace #-} #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/src/System/IO/Unsafe/Compat.hs new/base-compat-0.9.0/src/System/IO/Unsafe/Compat.hs --- old/base-compat-0.8.2/src/System/IO/Unsafe/Compat.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/src/System/IO/Unsafe/Compat.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,35 @@ +{-# LANGUAGE CPP, NoImplicitPrelude #-} +module System.IO.Unsafe.Compat ( + module Base +, unsafeFixIO +, unsafeDupablePerformIO +) where + +import System.IO.Unsafe as Base + +#if !(MIN_VERSION_base(4,5,0)) +import Control.Exception +import Data.IORef +import GHC.Base +import GHC.IO + +-- | A slightly faster version of `System.IO.fixIO` that may not be +-- safe to use with multiple threads. The unsafety arises when used +-- like this: +-- +-- > unsafeFixIO $ \r -> do +-- > forkIO (print r) +-- > return (...) +-- +-- In this case, the child thread will receive a @NonTermination@ +-- exception instead of waiting for the value of @r@ to be computed. +-- +-- /Since: 4.5.0.0/ +unsafeFixIO :: (a -> IO a) -> IO a +unsafeFixIO k = do + ref <- newIORef (throw NonTermination) + ans <- unsafeDupableInterleaveIO (readIORef ref) + result <- k ans + writeIORef ref result + return result +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Control/Monad/CompatSpec.hs new/base-compat-0.9.0/test/Control/Monad/CompatSpec.hs --- old/base-compat-0.8.2/test/Control/Monad/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Control/Monad/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,16 @@ +module Control.Monad.CompatSpec (main, spec) where + +import Test.Hspec + +import Control.Monad.Compat +import Prelude () +import Prelude.Compat + +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "(<$!>)" $ do + it "is a strict version of (<$>)" $ do + not <$!> [True, False] `shouldBe` not <$> [True, False] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Data/Bits/CompatSpec.hs new/base-compat-0.9.0/test/Data/Bits/CompatSpec.hs --- old/base-compat-0.8.2/test/Data/Bits/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Data/Bits/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,34 @@ +{-# LANGUAGE CPP #-} +module Data.Bits.CompatSpec (main, spec) where + +import Test.Hspec +import Data.Bits.Compat + +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "bitDefault" $ + it "sets the ith bit with all other bits clear" $ do + bitDefault 0 `shouldBe` (1 :: Int) + bitDefault 1 `shouldBe` (2 :: Int) + bitDefault 2 `shouldBe` (4 :: Int) + bitDefault 3 `shouldBe` (8 :: Int) + describe "testBitDefault" $ + it "returns True if the nth bit of the argument is 1" $ do + testBitDefault (10 :: Int) 0 `shouldBe` False + testBitDefault (10 :: Int) 1 `shouldBe` True + testBitDefault (10 :: Int) 2 `shouldBe` False + testBitDefault (10 :: Int) 3 `shouldBe` True + describe "popCountDefault" $ + it "returns the number of set bits in the argument" $ do + popCountDefault (0 :: Int) `shouldBe` 0 + popCountDefault (1 :: Int) `shouldBe` 1 + popCountDefault (10 :: Int) `shouldBe` 2 +#if MIN_VERSION_base(4,7,0) + describe "toIntegralSized" $ + it "converts an Integral type to another as measured by bitSizeMaybe" $ do + toIntegralSized (42 :: Integer) `shouldBe` (Just 42 :: Maybe Int) + toIntegralSized (12345678901234567890 :: Integer) `shouldBe` (Nothing :: Maybe Int) +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Data/Bool/CompatSpec.hs new/base-compat-0.9.0/test/Data/Bool/CompatSpec.hs --- old/base-compat-0.8.2/test/Data/Bool/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Data/Bool/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,18 @@ +module Data.Bool.CompatSpec (main, spec) where + +import Test.Hspec + +import Data.Bool.Compat + +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "bool" $ do + it "evaluates to first parameter if condition is False" $ do + bool "KO" "OK" False `shouldBe` "KO" + + it "evaluates to second parameter if condition is True" $ do + bool "KO" "OK" True `shouldBe` "OK" + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Data/Either/CompatSpec.hs new/base-compat-0.9.0/test/Data/Either/CompatSpec.hs --- old/base-compat-0.8.2/test/Data/Either/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Data/Either/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,25 @@ +module Data.Either.CompatSpec (main, spec) where + +import Test.Hspec + +import Data.Either.Compat + +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "isLeft" $ do + it "returns True for a Left value" $ do + isLeft (Left "23" :: Either String String) `shouldBe` True + + it "returns False for a Right value" $ do + isLeft (Right "23" :: Either String String) `shouldBe` False + + describe "isRight" $ do + it "returns False for a Left value" $ do + isRight (Left "23" :: Either String String) `shouldBe` False + + it "returns True for a Right value" $ do + isRight (Right "23" :: Either String String) `shouldBe` True + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Data/Function/CompatSpec.hs new/base-compat-0.9.0/test/Data/Function/CompatSpec.hs --- old/base-compat-0.8.2/test/Data/Function/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Data/Function/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,13 @@ +module Data.Function.CompatSpec (main, spec) where + +import Test.Hspec +import Data.Function.Compat + +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "&" $ do + it "reverses function application" $ do + (False & not) `shouldBe` True diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Data/Functor/CompatSpec.hs new/base-compat-0.9.0/test/Data/Functor/CompatSpec.hs --- old/base-compat-0.8.2/test/Data/Functor/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Data/Functor/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,17 @@ +module Data.Functor.CompatSpec (main, spec) where + +import Test.Hspec +import Data.Functor.Compat + +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "void" $ do + it "discards computation result" $ do + void (return 1 :: IO Int) `shouldReturn` () + + describe "$>" $ do + it "is the same as flipped <$" $ do + (Just 5 :: Maybe Int) $> 6 `shouldBe` (Just 6 :: Maybe Int) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Data/IORef/CompatSpec.hs new/base-compat-0.9.0/test/Data/IORef/CompatSpec.hs --- old/base-compat-0.8.2/test/Data/IORef/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Data/IORef/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,22 @@ +module Data.IORef.CompatSpec (main, spec) where + +import Test.Hspec + +import Control.Monad +import Data.IORef.Compat + +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "modifyIORef'" $ + it "mutates the contents of an IORef strictly" $ do + ref <- newIORef 0 + replicateM_ 1000000 $ modifyIORef' ref (+1) + readIORef ref `shouldReturn` (1000000 :: Int) + describe "atomicModifyIORef'" $ + it "atomically modifies the contents of an IORef strictly" $ do + ref <- newIORef 0 + replicateM_ 1000000 . atomicModifyIORef' ref $ \n -> (n+1, ()) + readIORef ref `shouldReturn` (1000000 :: Int) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Data/List/CompatSpec.hs new/base-compat-0.9.0/test/Data/List/CompatSpec.hs --- old/base-compat-0.8.2/test/Data/List/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Data/List/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,43 @@ +module Data.List.CompatSpec (main, spec) where + +import Test.Hspec +import Data.List.Compat + +data Asymmetric = A | B deriving Show + +instance Eq Asymmetric where + A == _ = True + B == _ = False + +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "dropWhileEnd" $ do + it "drops the largest suffix of a list in which a predicate holds for all elements" $ do + dropWhileEnd (== ' ') "foo " `shouldBe` "foo" + dropWhileEnd (== ' ') "foo bar" `shouldBe` "foo bar" + describe "isSubsequenceOf" $ do + it "returns True if the first list is a subsequence of the second list" $ do + isSubsequenceOf "GHC" "The Glorious Haskell Compiler" `shouldBe` True + isSubsequenceOf "JHC" "The Glorious Haskell Compiler" `shouldBe` False + describe "nub" $ + it "preserves the order of arguments to (==)" $ + nub [A, B] `shouldBe` [A] + describe "nubBy" $ + it "preserves the order of arguments to the equality function" $ + nubBy (<) "12" `shouldBe` "1" + describe "sortOn" $ do + it "sorts a list by comparing the results of a key function applied to each element" $ do + sortOn (>='b') "cba" `shouldBe` "acb" + describe "uncons" $ do + it "decomposes a list into its head and tail" $ do + uncons "" `shouldBe` Nothing + uncons "12" `shouldBe` Just ('1', "2") + describe "union" $ + it "nubs arguments in the same order as (==)" $ do + union [A] [A, B] `shouldBe` [A] + describe "unionBy" $ + it "nubs arguments in the same order as nubBy's equality function" $ do + unionBy (<) "1" "21" `shouldBe` "11" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Data/Monoid/CompatSpec.hs new/base-compat-0.9.0/test/Data/Monoid/CompatSpec.hs --- old/base-compat-0.8.2/test/Data/Monoid/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Data/Monoid/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,16 @@ +module Data.Monoid.CompatSpec (main, spec) where + +import Test.Hspec +import Test.QuickCheck + +import Data.Monoid.Compat + +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "<>" $ do + it "is an infix synonym for mappend" $ do + property $ \xs ys -> do + xs <> ys `shouldBe` (mappend xs ys :: String) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Data/STRef/CompatSpec.hs new/base-compat-0.9.0/test/Data/STRef/CompatSpec.hs --- old/base-compat-0.8.2/test/Data/STRef/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Data/STRef/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,19 @@ +module Data.STRef.CompatSpec (main, spec) where + +import Test.Hspec + +import Control.Monad +import Control.Monad.ST +import Data.STRef.Compat + +main :: IO () +main = hspec spec + +spec :: Spec +spec = + describe "modifySTRef'" $ + it "should mutate the contents of an STRef strictly" $ + shouldBe (1000000 :: Int) $ runST $ do + ref <- newSTRef 0 + replicateM_ 1000000 $ modifySTRef' ref (+1) + readSTRef ref diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Data/Version/CompatSpec.hs new/base-compat-0.9.0/test/Data/Version/CompatSpec.hs --- old/base-compat-0.8.2/test/Data/Version/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Data/Version/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,10 @@ +module Data.Version.CompatSpec (spec) where + +import Test.Hspec +import Data.Version.Compat + +spec :: Spec +spec = do + describe "makeVersion" $ + it "constructs a tagless Version" $ + makeVersion [1,2,3] `shouldBe` Version [1,2,3] [] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Data/Word/CompatSpec.hs new/base-compat-0.9.0/test/Data/Word/CompatSpec.hs --- old/base-compat-0.8.2/test/Data/Word/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Data/Word/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,22 @@ +module Data.Word.CompatSpec (main, spec) where + +import Test.Hspec +import Data.Word.Compat + +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "byteSwap16" $ + it "reverses the order of bytes in a Word16 value" $ do + byteSwap16 0x1100 `shouldBe` 0x0011 + byteSwap16 0x1010 `shouldBe` 0x1010 + describe "byteSwap32" $ + it "reverses the order of bytes in a Word32 value" $ do + byteSwap32 0x11001010 `shouldBe` 0x10100011 + byteSwap32 0x10101111 `shouldBe` 0x11111010 + describe "byteSwap64" $ + it "reverses the order of bytes in a Word64 value" $ do + byteSwap64 0x1010111110101111 `shouldBe` 0x1111101011111010 + byteSwap64 0x1100000000000011 `shouldBe` 0x1100000000000011 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Foreign/Marshal/Alloc/CompatSpec.hs new/base-compat-0.9.0/test/Foreign/Marshal/Alloc/CompatSpec.hs --- old/base-compat-0.8.2/test/Foreign/Marshal/Alloc/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Foreign/Marshal/Alloc/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,17 @@ +module Foreign.Marshal.Alloc.CompatSpec (main, spec) where + +import Test.Hspec + +import Control.Exception +import Foreign.Marshal.Alloc.Compat +import Foreign.Storable + +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "calloc" $ + it "allocates memory with bytes of value zero" $ do + bracket calloc free $ \ptr -> do + peek ptr `shouldReturn` (0 :: Int) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Foreign/Marshal/Utils/CompatSpec.hs new/base-compat-0.9.0/test/Foreign/Marshal/Utils/CompatSpec.hs --- old/base-compat-0.8.2/test/Foreign/Marshal/Utils/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Foreign/Marshal/Utils/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,20 @@ +module Foreign.Marshal.Utils.CompatSpec (main, spec) where + +import Test.Hspec + +import Foreign.Marshal.Alloc +import Foreign.Marshal.Utils.Compat +import Foreign.Ptr +import Foreign.Storable + +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "fillBytes" $ + it "fills a given number of bytes in memory area with a byte value" $ do + alloca $ \ptr -> do + let _ = ptr :: Ptr Int + fillBytes ptr 0 $ sizeOf ptr + peek ptr `shouldReturn` 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Numeric/CompatSpec.hs new/base-compat-0.9.0/test/Numeric/CompatSpec.hs --- old/base-compat-0.8.2/test/Numeric/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Numeric/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,24 @@ +module Numeric.CompatSpec (main, spec) where + +import Test.Hspec +import Numeric.Compat + +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "showFFloatAlt" $ do + it "shows a RealFloat value, always using decimal notation" $ + showFFloatAlt Nothing (12 :: Double) "" `shouldBe` "12.0" + it "allows to specify the number of decimal places" $ + showFFloatAlt (Just 4) (12 :: Double) "" `shouldBe` "12.0000" + describe "showGFloatAlt" $ do + it "shows a RealFloat value, using decimal notation if the absolute value lies between 0.1 and 9,999,999" $ + showGFloatAlt Nothing (12 :: Double) "" `shouldBe` "12.0" + it "shows a RealFloat value, using decimal notation and specifying the number of decimal places" $ + showGFloatAlt (Just 4) (12 :: Double) "" `shouldBe` "12.0000" + it "shows a RealFloat value, using scientific notation if the absolute value falls outside of the range" $ + showGFloatAlt Nothing (1234567890 :: Double) "" `shouldBe` "1.23456789e9" + it "shows a RealFloat value, using scientific notation and specifying the number of decimal places" $ + showGFloatAlt (Just 4) (1234567890 :: Double) "" `shouldBe` "1.2346e9" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/System/Environment/CompatSpec.hs new/base-compat-0.9.0/test/System/Environment/CompatSpec.hs --- old/base-compat-0.8.2/test/System/Environment/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/System/Environment/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,120 @@ +{-# LANGUAGE CPP #-} +module System.Environment.CompatSpec (main, spec) where + +import Test.Hspec +import Test.QuickCheck + +import qualified Control.Exception as E +import GHC.IO.Exception (IOErrorType (InvalidArgument)) +import System.Environment.Compat +import System.IO.Error + +main :: IO () +main = hspec spec + +withEnv :: String -> String -> IO a -> IO a +withEnv k v action = E.bracket save restore $ \_ -> do + setEnv k v >> action + where + save = lookupEnv k + restore = maybe (unsetEnv k) (setEnv k) + +withoutEnv :: String -> IO a -> IO a +withoutEnv k action = E.bracket save restore $ \_ -> do + unsetEnv k >> action + where + save = lookupEnv k + restore = maybe (unsetEnv k) (setEnv k) + +spec :: Spec +spec = do + describe "lookupEnv" $ do + it "returns specified environment variable" $ do + withEnv "FOOBAR" "23" $ do + lookupEnv "FOOBAR" `shouldReturn` Just "23" + + it "returns Nothing if specified environment variable is not set" $ do + withoutEnv "FOOBAR" $ do + lookupEnv "FOOBAR" `shouldReturn` Nothing + + describe "unsetEnv" $ do + it "removes specified environment variable" $ do + setEnv "FOO" "foo" + unsetEnv "FOO" + getEnv "FOO" `shouldThrow` isDoesNotExistError + + it "does nothing if specified environment variable is not set" $ do + unsetEnv "BAR" + unsetEnv "BAR" + getEnv "BAR" `shouldThrow` isDoesNotExistError + + it "throws an exception if key is the empty string" $ do + unsetEnv "" `shouldThrow` (== InvalidArgument) . ioeGetErrorType + + it "throws an exception if key contains '='" $ do + unsetEnv "some=key" `shouldThrow` (== InvalidArgument) . ioeGetErrorType + + it "works for arbitrary keys" $ + property $ \k -> ('\NUL' `notElem` k && '=' `notElem` k && (not . null) k) ==> do + setEnv k "foo" + unsetEnv k + getEnv k `shouldThrow` isDoesNotExistError + + describe "setEnv" $ do + it "sets specified environment variable to given value" $ do + unsetEnv "FOO" + setEnv "FOO" "foo" + getEnv "FOO" `shouldReturn` "foo" + + it "resets specified environment variable, if it is already set" $ do + unsetEnv "FOO" + setEnv "FOO" "foo" + setEnv "FOO" "bar" + getEnv "FOO" `shouldReturn` "bar" + + it "removes specified environment variable when value is the empty string" $ do + setEnv "FOO" "foo" + setEnv "FOO" "" + getEnv "FOO" `shouldThrow` isDoesNotExistError + + it "removes specified environment variable when first character of value is NUL" $ do + setEnv "FOO" "foo" + setEnv "FOO" "\NULfoo" + getEnv "FOO" `shouldThrow` isDoesNotExistError + + it "truncates value at NUL character" $ do + unsetEnv "FOO" + setEnv "FOO" "foo\NULbar" + getEnv "FOO" `shouldReturn` "foo" + + it "truncates key at NUL character" $ do + unsetEnv "FOO" + setEnv "FOO\NULBAR" "foo" + getEnv "FOO" `shouldReturn` "foo" + +#if __GLASGOW_HASKELL__ >= 702 + it "works for unicode" $ do + unsetEnv "FOO" + setEnv "FOO" "foo-\955-bar" + getEnv "FOO" `shouldReturn` "foo-\955-bar" +#endif + + it "works for arbitrary values" $ + property $ \v -> ('\NUL' `notElem` v && (not . null) v) ==> do + setEnv "FOO" v + getEnv "FOO" `shouldReturn` v + + it "works for unicode keys" $ do + setEnv "foo-\955-bar" "foo" + getEnv "foo-\955-bar" `shouldReturn` "foo" + + it "throws an exception if key is the empty string" $ do + setEnv "" "foo" `shouldThrow` (== InvalidArgument) . ioeGetErrorType + + it "throws an exception if key contains '='" $ do + setEnv "some=key" "foo" `shouldThrow` (== InvalidArgument) . ioeGetErrorType + + it "works for arbitrary keys" $ + property $ \k -> ('\NUL' `notElem` k && '=' `notElem` k && (not . null) k) ==> do + setEnv k "foo" + getEnv k `shouldReturn` "foo" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/base-compat-0.8.2/test/Text/Read/CompatSpec.hs new/base-compat-0.9.0/test/Text/Read/CompatSpec.hs --- old/base-compat-0.8.2/test/Text/Read/CompatSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/base-compat-0.9.0/test/Text/Read/CompatSpec.hs 2016-01-15 03:45:49.000000000 +0100 @@ -0,0 +1,24 @@ +module Text.Read.CompatSpec (main, spec) where + +import Test.Hspec + +import Text.Read.Compat + +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "readMaybe" $ do + it "parses a value" $ do + readMaybe "23" `shouldBe` (Just 23 :: Maybe Int) + + it "returns Nothing if parsing fails" $ do + readMaybe "xx" `shouldBe` (Nothing :: Maybe Int) + + describe "readEither" $ do + it "parses a value" $ do + readEither "23" `shouldBe` (Right 23 :: Either String Int) + + it "returns Left if parsing fails" $ do + readEither "xx" `shouldBe` (Left "Prelude.read: no parse" :: Either String Int)
participants (1)
-
root@hilbert.suse.de