From 16a3288cce270b3a8b03a85e2f3a0fb321c125ee Mon Sep 17 00:00:00 2001 From: Lex Spoon Date: Fri, 23 Mar 2007 16:45:25 +0000 Subject: added test for unapply in Streams --- test/files/run/patmatnew.scala | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'test/files/run/patmatnew.scala') diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala index 46e980dff0..89b9afb32b 100644 --- a/test/files/run/patmatnew.scala +++ b/test/files/run/patmatnew.scala @@ -20,7 +20,8 @@ object Test extends TestConsoleMain { def suite = new TestSuite( new TestSimpleIntSwitch, new Test717, - new TestGuards + new TestGuards, + new TestStream ) @@ -70,6 +71,18 @@ object Test extends TestConsoleMain { } } + class TestStream extends TestCase("unapply for Streams") { + def sum(stream: Stream[int]): int = + stream match { + case Stream.empty => 0 + case Stream.cons(hd, tl) => hd + sum(tl) + } + + val str: Stream[int] = Stream.fromIterator(List(1,2,3).elements) + + def runTest() = assertEquals(sum(str), 6) + } + class Test806_818 { // #806, #811 compile only -- type of bind // bug811 trait Core { -- cgit v1.2.3