brittany/data/10-structured/fundecl.blt

95 lines
2.3 KiB
Plaintext

###############################################################################
#group decl/binding/basic
###############################################################################
#test basic 1
func x = x
#test infix 1
x *** y = x
#test symbol prefix
(***) x y = x
#test infix more args simple
(f >=> g) k = f k >>= g
#test infix more args alignment
(Left a <$$> Left dd) e f = True
(Left a <$$> Right d ) e f = True
(Right a <$$> Left d ) e f = False
(Right a <$$> Right dd) e f = True
###############################################################################
#group decl/binding/patterns
###############################################################################
#test wildcard
func _ = x
#test simple long pattern
func reallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongvariable =
x
#test simple multiline pattern
func reallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongvariable reallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongvariable
= x
#test another multiline pattern
func reallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongvariable a b
= x
#test simple constructor
func (A a) = a
#test list constructor
func (x : xr) = x
#test some other constructor symbol
func (x :+: xr) = x
#test normal infix constructor
func (x `Foo` xr) = x
###############################################################################
#group decl/binding/guards
###############################################################################
#test simple guard
func | True = x
#test multiple-clauses-1
func x | x = simple expression
| otherwise = 0
#test multiple-clauses-2
func x
| a somewhat longer guard x = "and a somewhat longer expession that does not"
| otherwise = "fit without putting the guards in new lines"
#test multiple-clauses-3
func x
| very long guard, another rather long guard that refers to x = nontrivial
expression
foo
bar
alsdkjlasdjlasj
| otherwise = 0
#test multiple-clauses-4
func x
| very long guard, another rather long guard that refers to x
= nontrivialexpression foo bar alsdkjlasdjlasj
| otherwise
= 0
#test multiple-clauses-5
func x
| very loooooooooooooooooooooooooooooong guard
, another rather long guard that refers to x
= nontrivial expression foo bar alsdkjlasdjlasj
| otherwise
= 0