X-Git-Url: http://nitlanguage.org diff --git a/tests/test_meta.nit b/tests/test_meta.nit index b649f99..936982e 100644 --- a/tests/test_meta.nit +++ b/tests/test_meta.nit @@ -1,7 +1,5 @@ # This file is part of NIT ( http://www.nitlanguage.org ). # -# Copyright 2004-2008 Jean Privat -# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -14,74 +12,45 @@ # See the License for the specific language governing permissions and # limitations under the License. +import meta -class A - fun foo - do - printn("A") - end - fun blup(a: Int) - do - blup2(a, 1) - end - fun blup2(a: Int, b : Int) - do - printn(a+b) - end - fun blop(a: Int, b: Int...) - do - var i = b.iterator - while i.is_ok do - printn(a+i.item) - i.next - end - end +class XObject + redef type CLASS: XClass[SELF] + redef fun class_factory(name) do return new XClass[SELF](name) end -class B - super A - redef fun foo - do - printn("B") - end +class XClass[E: XObject] + super Class[E] end -class C - super A - fun foo2 - do - printn("C") - end +class YObject + redef type CLASS: YClass[SELF] + redef fun class_factory(name) do return new YClass[SELF](name) end -class D - super B - super C - redef fun foo - do - printn("D") - end - - init do end +class YClass[E: YObject] + super Class[E] + super YObject # Yeah, a meta-loop! end -fun test1 -do - var b: B - b = new D - b.foo - b.blup2(1,2) - b.blup(3) -end +var s = "hello" +print s.class_name +print s.get_class +print s.get_class.get_class +print s.get_class.get_class.get_class -fun test2 -do - var b = new D - var a = [1,2,3] - var u: Object - printn("=",5) - b.blop(5,2,3) -end +print "" + +var x = new XObject +print x.class_name +print x.get_class +print x.get_class.get_class +print x.get_class.get_class.get_class + +print "" -test1 -test2 +var y = new YObject +print y.class_name +print y.get_class +print y.get_class.get_class +print y.get_class.get_class.get_class