tests: add base_upcast
[nit.git] / tests / base_upcast2.nit
diff --git a/tests/base_upcast2.nit b/tests/base_upcast2.nit
new file mode 100644 (file)
index 0000000..476c44b
--- /dev/null
@@ -0,0 +1,41 @@
+import kernel
+
+class A[E]
+end
+
+class B[G] super A[Int]
+end
+
+class C super B[Bool]
+end
+
+class X
+       #1alt1#type T: A[Int]
+       #1alt2#type T: A[Bool]
+       #1alt3#type T: B[Int]
+       #1alt4#type T: B[Bool]
+       #1alt5#type T: C
+       fun toto
+       do
+               var ai = new A[Int]
+               var ab = new A[Bool]
+               var bi = new B[Int]
+               var bb = new B[Bool]
+               var c = new C
+
+               var t: T = c.as(T)
+               #alt1#if maybe then t = ai
+               #alt2#if maybe then t = ab
+               #alt3#if maybe then t = bi
+               #alt4#if maybe then t = bb
+               #alt5#if maybe then t = c
+               #alt6#if maybe then ai = t
+               #alt7#if maybe then ab = t
+               #alt8#if maybe then bi = t
+               #alt9#if maybe then bb = t
+               #alt10#if maybe then c = t
+       end
+end
+
+fun maybe: Bool do return true
+