Skip to content

Commit 117b9de

Browse files
committed
Fix test
Fix SemanticDB test and add another test
1 parent 815f479 commit 117b9de

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

tests/run/defunctionalized.check

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
List(2, 4)
2+
List(1, 2, 3, 5)
3+
List(1, 2, 3)

tests/run/defunctionalized.scala

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
enum Filter:
2+
case IsOdd
3+
case IsPrime
4+
case LessThan(bound: Int)
5+
case And(f1: Filter, f2: Filter)
6+
7+
def apply(x: Int): Boolean = this match
8+
case IsOdd => x % 2 == 0
9+
case IsPrime => (2 until x).forall(y => x % y != 0)
10+
case LessThan(bound) => x < bound
11+
case And(f1, f2) => f1(x) && f2(x)
12+
13+
def filter(f: Filter, elems: List[Int]): List[Int] = elems match
14+
case Nil => Nil
15+
case x :: xs =>
16+
if f(x) then x :: filter(f, xs)
17+
else filter(f, xs)
18+
19+
val xs = List(1, 2, 3, 4, 5)
20+
21+
import Filter._
22+
23+
@main def Test =
24+
println(filter(IsOdd , xs))
25+
println(filter(IsPrime , xs))
26+
println(filter(LessThan(4), xs))

tests/semanticdb/expect/Enums.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ object Enums:
4646
enum <:<[-A, B]:
4747
case Refl[C]() extends (C <:< C)
4848

49-
object <:<:
49+
object <:< :
5050
given [T]: (T <:< T) = Refl()
5151

5252
def [A, B](opt: Option[A]) unwrap(given ev: A <:< Option[B]): Option[B] = ev match

0 commit comments

Comments
 (0)