/src-extra/tests/Database/HsSqlPpp/Tests/junk/PrecisionTests.lhs

http://github.com/JakeWheat/hssqlppp · Haskell · 42 lines · 39 code · 3 blank · 0 comment · 1 complexity · 10786b0e185883789ac479c1f76036f1 MD5 · raw file

  1. This code tests the typechecking of precision types, at the moment
  2. this is limited to numeric, char and varchar.
  3. numeric:
  4. unary closed operators: returns same precision as input
  5. binary closed operators: returns highest precision of two inputs (have
  6. to combine if also have scales)
  7. tricky: int8 factorial (!,!!) returns numeric, what precision?
  8. few other fns whose input is not numeric, but output is
  9. casts to numeric: what precision?
  10. > module Database.HsSqlPpp.Tests.TypeChecking.PrecisionTests
  11. > (precisionTests
  12. > ,precisionTestData
  13. > ,Item(..)) where
  14. >
  15. > import Test.HUnit
  16. > import Test.Framework
  17. > import Test.Framework.Providers.HUnit
  18. > --import Data.List
  19. > import Data.Generics.Uniplate.Data
  20. > import Control.Monad
  21. >
  22. > --import Database.HsSqlPpp.Utils.Here
  23. > import Database.HsSqlPpp.Parser
  24. > import Database.HsSqlPpp.TypeChecker
  25. > import Database.HsSqlPpp.Annotation
  26. > import Database.HsSqlPpp.Catalog
  27. > import Database.HsSqlPpp.SqlTypes
  28. > import Database.HsSqlPpp.Utils.PPExpr
  29. > --import Database.HsSqlPpp.Tests.TestUtils
  30. > import Database.HsSqlPpp.PrettyPrinter
  31. >
  32. > data Item = Group String [Item]
  33. > | Query [CatalogUpdate] String Type
  34. >
  35. > precisionTests :: Test.Framework.Test
  36. > precisionTests = itemToTft precisionTestData
  37. >
  38. > precisionTestData :: Item
  39. > precisionTestData = Group "precision typechecking" []