Skip to content

Commit 7feb0f2

Browse files
committed
Test cases
1 parent 1725644 commit 7feb0f2

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

tests/pos/flowops1.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ object Test {
2020
def xx(i: Int): f.Repr[Out = O] = f.map(identity)
2121
}
2222

23+
class xalt[O, M, F <: FO](val f: F[Out = O, Mat = M]) extends AnyVal {
24+
def xx(i: Int): FO[Out = O, Mat = M] = ???
25+
}
26+
2327
val s1 = new Source[Int, NotUsed].xx(12)
2428
val s2: Source[Int, NotUsed] = s1
2529
val f1 = x[Int, NotUsed, Flow[In = Int]](new Flow[Int, Int, NotUsed]).xx(12)
@@ -30,4 +34,6 @@ object Test {
3034
val f4: Flow[Int, Int, NotUsed] = f3
3135
val f5 = new Flow[Int, Int, NotUsed].xx(12)
3236
val f6: Flow[Int, Int, NotUsed] = f5
37+
val f7 = new xalt(new Flow[Int, Int, NotUsed]).xx(12)
38+
val f8: FO[Int, NotUsed] = f7
3339
}

tests/pos/named-params.scala

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,39 @@ object Test {
2929
val z3 = d2[E = Int](1)
3030
val z4 = d2[V = Int]("AAA")
3131
val z5 = d2[E = Int][V = String](1)
32+
33+
// Testing type inference
34+
35+
def f[X <: C](x: X[Int, Int]): X[String, String] = ???
36+
val arg1: C[Int, Int] = ???
37+
val res1 = f(arg1)
38+
val chk1: C[String, String] = res1
39+
40+
class C1[type Elem, type Value](x: Elem) extends C[Elem, Value](x)
41+
class CC extends C1[Int, Int](1)
42+
val arg2: CC = ???
43+
val res2 = f(arg2)
44+
val chk2: C[String, String] = res2
45+
46+
class D1[type Elem, type Value](x: Elem) extends C[Elem, Value](x)
47+
class DD extends D1[Int, Int](2)
48+
val arg3: CC & DD = ???
49+
val res3 = f(arg3)
50+
val chk3: (C1 & D1) { type Elem = String; type Value = String } = res3
51+
val arg4: CC | DD = ???
52+
val res4 = f(arg4)
53+
val chk4: C[String, String] = ???
54+
55+
class CX[type Elem](x: Elem) extends C1[Elem, Int](x)
56+
class DX[type Value]() extends D1[Int, Value](2)
57+
val arg5: CX[Int] & DX[Int] = ???
58+
val res5 = f(arg5)
59+
val chk5: (C1 & D1) { type Elem = String; type Value = String } = res5
60+
val chk6: C1[String, String] & D1[String, String] = chk5
61+
val chk7: (C1 & D1) { type Elem = String; type Value = String } = chk6
3262
}
3363

34-
// Adapated from i94-nada
64+
// Adapted from i94-nada, somewhat non-sensical
3565
trait Test1 {
3666
trait Monad[type Elem] {
3767
def unit: Elem
@@ -40,7 +70,21 @@ trait Test1 {
4070
case class Left[A,B](unit: A) extends Either[A,B] with Monad[A]
4171
case class Right[A,B](unit: B) extends Either[A,B] with Monad[B]
4272
def flatMap[X,Y,M <: Monad](m: M[Elem = X], f: X => M[Elem = Y]): M[Elem = Y] = f(m.unit)
43-
println(flatMap(Left(1), {x: Int => Left(x)}))
73+
val res = flatMap(Left(1), {x: Int => Left(x)})
74+
val chk: Either[Int, Nothing] & Monad & Product1[Int] = res
75+
}
76+
77+
// Adapted from i94-nada, this time with more sense
78+
trait Test2 {
79+
trait Monad[type Elem] {
80+
def unit: Elem
81+
}
82+
sealed abstract class Either[A,B]
83+
case class Left[type Elem, B](unit: Elem) extends Either[Elem,B] with Monad[Elem]
84+
case class Right[A, type Elem](unit: Elem) extends Either[A,Elem] with Monad[Elem]
85+
def flatMap[X,Y,M <: Monad](m: M[Elem = X], f: X => M[Elem = Y]): M[Elem = Y] = f(m.unit)
86+
val res = flatMap(Left(1), {x: Int => Left(x)})
87+
val chk: Left[Int, Nothing] = res
4488
}
4589

4690

0 commit comments

Comments
 (0)