Commit b72aa2c9 authored by mikhail.vorozhtsov's avatar mikhail.vorozhtsov Committed by Simon Marlow

Added LambdaCase tests.

parent 49703b98
{-# LANGUAGE LambdaCase #-}
module Main where
f = curry $ \case (Just x, Left y) -> Just (x, y)
(Nothing, Right y) | y == 99 -> Just (0, "99")
_ -> Nothing
main = print $ [ f (Just 1) (Left "Y") == Just (1, "Y")
, f (Just 1) (Right 99) == Nothing
, f Nothing (Right 99) == Just (0, "99")
, f Nothing (Right 9) == Nothing
, f Nothing (Left "Y") == Nothing ]
......@@ -38,3 +38,4 @@ test('mc06', normal, compile_and_run, [''])
test('mc07', normal, compile_and_run, [''])
test('mc08', normal, compile_and_run, [''])
test('T5742', normal, compile_and_run, [''])
test('DsLambdaCase', if_compiler_lt('ghc', '7.5', skip), compile_and_run, [''])
{-# LANGUAGE LambdaCase #-}
module ParserLambdaCase where
f1 = \case "1" -> 1
f2 = \ {- comment1 {- comment2 -} -} case "1" -> 1; "2" -> 2
f3 = \ -- comment
case "1" -> 1
"2" -> 2
f4 = \casex -> casex
f5 = \ case { "1" -> 1; "2" -> 2 }
......@@ -90,6 +90,7 @@ test('NondecreasingIndentation', normal, compile, [''])
test('mc15', normal, compile, [''])
test('mc16', normal, compile, [''])
test('EmptyDecls', normal, compile, [''])
test('ParserLambdaCase', if_compiler_lt('ghc', '7.5', skip), compile, [''])
test('T5243', extra_clean(['T5243A.hi', 'T5243A.o']),
multimod_compile, ['T5243',''])
......
module ParserNoLambdaCase where
f = \case "1" -> 1
ParserNoLambdaCase.hs:3:6: parse error on input `case'
......@@ -72,5 +72,6 @@ test('NondecreasingIndentationFail', normal, compile_fail, [''])
test('readFailTraditionalRecords1', normal, compile_fail, [''])
test('readFailTraditionalRecords2', normal, compile_fail, [''])
test('readFailTraditionalRecords3', normal, compile_fail, [''])
test('ParserNoLambdaCase', if_compiler_lt('ghc', '7.5', skip), compile_fail, [''])
test('T5425', normal, compile_fail, [''])
{-# LANGUAGE LambdaCase #-}
module TcLambdaCase where
import Data.Bits ((.|.))
f1 :: (a -> a) -> (a -> a)
f1 = \case x -> x
f2 :: Num a => a -> a
f2 = \case x -> x + x
f3 :: Int -> (Int, Int)
f3 = (\case y -> (y + y, y * y)) . (.|. 12)
f4 = \case _ -> undefined
......@@ -380,3 +380,4 @@ test('T6055', normal, compile, [''])
test('DfltProb1', normal, compile, [''])
test('DfltProb2', normal, compile, [''])
test('T6134', normal, compile, [''])
test('TcLambdaCase', if_compiler_lt('ghc', '7.5', skip), compile, [''])
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