Commit efb6ce6e authored by claus.reinke@talk21.com's avatar claus.reinke@talk21.com
Browse files

tests for :browse!, :{:}, :set, :show languages/packages

these tests validate on win/xp.

  - if any issues with dos-style line-endings remain,
    please apply dos2unix for now, and let me know

  - ghci024 has ghci024.py instead of ghci024.stdout;
    the prepare024 function defined in there generates
    a platform- and version-specific ghci024.stdout
    for the test (see all.T)

  - ghci025 uses the (non-advertised) new -s option
    to get sorted :browse output for stable tests
    (to work around #1799). if this isn't sufficient,
    please set normal to ignore_output in all.T for
    now (until #1799 is fixed), and let me know
parent f983a215
...@@ -31,4 +31,9 @@ test('ghci020', normal, ghci_script, ['ghci020.script']) ...@@ -31,4 +31,9 @@ test('ghci020', normal, ghci_script, ['ghci020.script'])
test('ghci021', normal, ghci_script, ['ghci021.script']) test('ghci021', normal, ghci_script, ['ghci021.script'])
test('ghci022', normal, ghci_script, ['ghci022.script']) test('ghci022', normal, ghci_script, ['ghci022.script'])
test('ghci023', normal, ghci_script, ['ghci023.script'])
execfile(in_testdir('ghci024.py')) # load function prepare024
test('ghci024', prepare024, ghci_script, ['ghci024.script'])
test('ghci025', normal, ghci_script, ['ghci025.script'])
test('ghci026', namebase_if_compiler_lt('ghc','6.9', 'ghci026-6.8'), ghci_script, ['ghci026.script']) test('ghci026', namebase_if_compiler_lt('ghc','6.9', 'ghci026-6.8'), ghci_script, ['ghci026.script'])
:{
let { a = True
; b = False
}
:}
print (a,b)
:{
:type
id
:}
putStrLn "-- testing ghci multiline commands :{ .. :}"
putStrLn "-- via stdin"
:{
let
{ f 0 = 1
; f 1 = w
where { w = 2 }
; y = 3
}
:}
print (f 0,f 1,y)
:{
:browse
Data.Maybe
:}
putStrLn "-- via readFile"
:cmd readFile "ghci023.ghci"
-- testing ghci multiline commands :{ .. :}
-- via stdin
(1,2,3)
data Maybe a = Nothing | Just a
catMaybes :: [Maybe a] -> [a]
fromJust :: Maybe a -> a
fromMaybe :: a -> Maybe a -> a
isJust :: Maybe a -> Bool
isNothing :: Maybe a -> Bool
listToMaybe :: [a] -> Maybe a
mapMaybe :: (a -> Maybe b) -> [a] -> [b]
maybe :: b -> (a -> b) -> Maybe a -> b
maybeToList :: Maybe a -> [a]
-- via readFile
(True,False)
id :: a -> a
import os
import re
conf_ghc = '/cygdrive/c/fptools/ghc/compiler/stage2/ghc-inplace'
def prepare024( opts ):
h = os.popen('echo :q | '+config.compiler+' --interactive -package ghc ')
packages = h.read()
h.close()
packagelist = []
for l in packages.splitlines():
if re.match('^Loading package',l):
packagelist += [re.sub(r'^Loading package (\S*) .*$',r'\1',l)]
packagelist.reverse()
packagelist += ['rts']
outtext = """\
options currently set: none.
GHCi-specific dynamic flag settings:
-fno-print-explicit-foralls
-fprint-bind-result
-fno-break-on-exception
-fno-break-on-error
-fno-print-evld-with-show
other dynamic, non-language, flag settings:
-fno-warn-dodgy-imports
-fwarn-duplicate-exports
-fno-warn-hi-shadowing
-fno-warn-implicit-prelude
-fno-warn-incomplete-patterns
-fno-warn-incomplete-record-updates
-fwarn-missing-fields
-fwarn-missing-methods
-fno-warn-missing-signatures
-fno-warn-name-shadowing
-fwarn-overlapping-patterns
-fno-warn-simple-patterns
-fno-warn-type-defaults
-fno-warn-monomorphism-restriction
-fno-warn-unused-binds
-fno-warn-unused-imports
-fno-warn-unused-matches
-fwarn-deprecations
-fno-warn-orphans
-fno-warn-tabs
-fno-strictness
-fno-full-laziness
-fno-liberate-case
-fno-spec-constr
-fno-cse
-fignore-interface-pragmas
-fomit-interface-pragmas
-fdo-lambda-eta-expansion
-fno-ignore-asserts
-fno-ignore-breakpoints
-fno-do-eta-reduction
-fno-case-merge
-fno-unbox-strict-fields
-fno-dicts-cheap
-fno-excess-precision
-fasm-mangling
-fno-force-recomp
-fno-hpc-no-auto
-fno-rewrite-rules
-fno-run-cps
-fno-convert-to-zipper-and-back
-fno-vectorise
-fno-regs-graph
-fno-regs-iterative
-fgen-manifest
-fembed-manifest
active language flags:
-XImplicitPrelude
-XMonomorphismRestriction
-XMonoPatBinds
-- :set -fglasgow-exts
active language flags:
-XPatternGuards
-XUnicodeSyntax
-XMagicHash
-XPolymorphicComponents
-XExistentialQuantification
-XKindSignatures
-XPatternSignatures
-XEmptyDataDecls
-XParallelListComp
-XForeignFunctionInterface
-XUnliftedFFITypes
-XLiberalTypeSynonyms
-XRankNTypes
-XTypeOperators
-XRecursiveDo
-XImplicitPrelude
-XGADTs
-XTypeFamilies
-XMonomorphismRestriction
-XMonoPatBinds
-XRelaxedPolyRec
-XImplicitParams
-XScopedTypeVariables
-XUnboxedTuples
-XStandaloneDeriving
-XDeriveDataTypeable
-XTypeSynonymInstances
-XFlexibleContexts
-XFlexibleInstances
-XConstrainedClassMethods
-XMultiParamTypeClasses
-XFunctionalDependencies
-XGeneralizedNewtypeDeriving
active package flags: none
packages currently loaded:
base
rts
-- :set -package ghc
active package flags:
-package ghc
packages currently loaded:
"""
outfile = open(in_testdir('ghci024.stdout'), 'w')
outfile.write(outtext)
for l in packagelist: outfile.write(' '+l+'\n')
outfile.close()
return;
:set
:show languages
putStrLn "-- :set -fglasgow-exts"
:set -fglasgow-exts
:show languages
:show packages
putStrLn "-- :set -package ghc"
:set -package ghc
:show packages
package flags have changed, ressetting and loading new packages...
{-# OPTIONS_GHC -fglasgow-exts #-}
{-# OPTIONS_GHC -fglasgow-exts #-}
module T where
import qualified Prelude as T(length,Monad)
import qualified Data.ByteString as T(length)
import Prelude(length,(+),(=<<),Monad(..),Maybe(..),Eq)
import Data.Maybe
import Control.Monad(Monad(..),MonadPlus(..))
length = 0
class N a
class S a
class C a b where
c1 :: N b => a -> b
c2 :: (N b,S b) => a -> b
c3 :: forall a. a -> b
c4 :: a1 -> b
:l ghci025
System.IO.putStrLn "test :browse! functionality"
System.IO.putStrLn ":browse! -s *T -- sort output to get deterministic result (#1799)"
:browse! *T
System.IO.putStrLn ":browse! T"
:browse! T
:set -fglasgow-exts
System.IO.putStrLn ":browse! T -- with -fglasgow-exts"
:browse! T
test :browse! functionality
:browse! -s *T -- sort output to get deterministic result (#1799)
-- defined locally
T.length :: GHC.Num.Integer
class N a
class S a
class C a b where
c1 :: (N b) => a -> b
c2 :: (N b, S b) => a -> b
c3 :: a1 -> b
c4 :: a1 -> b
c1 :: (C a b, N b) => a -> b
c2 :: (C a b, N b, S b) => a -> b
c3 :: (C a b) => a1 -> b
c4 :: (C a b) => a1 -> b
-- imported from Control.Monad
class (Monad m) => MonadPlus m where
mzero :: m a
mplus :: m a -> m a -> m a
mplus :: (MonadPlus m) => m a -> m a -> m a
mzero :: (MonadPlus m) => m a
-- imported from Control.Monad, Prelude
(>>) :: (Monad m) => m a -> m b -> m b
(>>=) :: (Monad m) => m a -> (a -> m b) -> m b
fail :: (Monad m) => GHC.Base.String -> m a
return :: (Monad m) => a -> m a
-- imported from Control.Monad, Prelude, T
class Monad m where
(>>=) :: m a -> (a -> m b) -> m b
(>>) :: m a -> m b -> m b
return :: a -> m a
fail :: GHC.Base.String -> m a
-- imported from Data.Maybe
catMaybes :: [Maybe a] -> [a]
fromJust :: Maybe a -> a
fromMaybe :: a -> Maybe a -> a
isJust :: Maybe a -> GHC.Base.Bool
isNothing :: Maybe a -> GHC.Base.Bool
listToMaybe :: [a] -> Maybe a
mapMaybe :: (a -> Maybe b) -> [a] -> [b]
maybe :: b -> (a -> b) -> Maybe a -> b
maybeToList :: Maybe a -> [a]
-- imported from Data.Maybe, Prelude
Just :: a -> Maybe a
data Maybe a = Nothing | Just a
Nothing :: Maybe a
-- imported from Prelude
(+) :: (GHC.Num.Num a) => a -> a -> a
(=<<) :: (Monad m) => (a -> m b) -> m a -> m b
class Eq a where
(GHC.Base.==) :: a -> a -> GHC.Base.Bool
(GHC.Base./=) :: a -> a -> GHC.Base.Bool
-- imported from Prelude, T
Prelude.length :: [a] -> GHC.Base.Int
-- imported from T
T.length :: Data.ByteString.Internal.ByteString -> GHC.Base.Int
:browse! T
-- defined locally
T.length :: Integer
class N a
class S a
class C a b where
c1 :: (N b) => a -> b
c2 :: (N b, S b) => a -> b
c3 :: a1 -> b
c4 :: a1 -> b
c1 :: (C a b, N b) => a -> b
c2 :: (C a b, N b, S b) => a -> b
c3 :: (C a b) => a1 -> b
c4 :: (C a b) => a1 -> b
:browse! T -- with -fglasgow-exts
-- defined locally
T.length :: Integer
class N a
class S a
class C a b where
c1 :: (N b) => a -> b
c2 :: (N b, S b) => a -> b
c3 :: forall a1. a1 -> b
c4 :: forall a1. a1 -> b
c1 :: forall a b. (C a b, N b) => a -> b
c2 :: forall a b. (C a b, N b, S b) => a -> b
c3 :: forall a b. (C a b) => forall a1. a1 -> b
c4 :: forall a b. (C a b) => forall a1. a1 -> b
data Maybe a = Nothing | Just a data Maybe a = Nothing | Just a
maybe :: b -> (a -> b) -> Maybe a -> b catMaybes :: [Maybe a] -> [a]
isJust :: Maybe a -> Bool
isNothing :: Maybe a -> Bool
fromJust :: Maybe a -> a fromJust :: Maybe a -> a
fromMaybe :: a -> Maybe a -> a fromMaybe :: a -> Maybe a -> a
maybeToList :: Maybe a -> [a] isJust :: Maybe a -> Bool
isNothing :: Maybe a -> Bool
listToMaybe :: [a] -> Maybe a listToMaybe :: [a] -> Maybe a
catMaybes :: [Maybe a] -> [a]
mapMaybe :: (a -> Maybe b) -> [a] -> [b] mapMaybe :: (a -> Maybe b) -> [a] -> [b]
maybe :: b -> (a -> b) -> Maybe a -> b
maybeToList :: Maybe a -> [a]
data T = A Int | B Float data T = A Int | B Float
f :: Double -> Double f :: Double -> Double
f :: Double -> Double
g :: Double -> Double g :: Double -> Double
h :: (Integral a) => a -> a h :: (Integral a) => a -> a
f :: Double -> Double
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment