[Nice-commit] Nice/testsuite/compiler/classes initializer.testsuite,1.15,1.16
Brought to you by:
bonniot
From: Daniel B. <bo...@us...> - 2004-10-08 17:56:10
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31174/testsuite/compiler/classes Modified Files: initializer.testsuite Log Message: Test initializers with subclassing in a different package, and that initializers are only executed once. Index: initializer.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/initializer.testsuite,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** initializer.testsuite 11 Jun 2004 05:01:39 -0000 1.15 --- initializer.testsuite 8 Oct 2004 17:56:00 -0000 1.16 *************** *** 4,13 **** let int cst = 42; ! class A { int i; ! { ! int j = i; assert j == cst; } --- 4,13 ---- let int cst = 42; ! class A { int i; ! { ! int j = i; assert j == cst; } *************** *** 16,20 **** /// FAIL /// Toplevel ! class A { int i; --- 16,20 ---- /// FAIL /// Toplevel ! class A { int i; *************** *** 31,35 **** /// Toplevel ! class A { { throw new Error(); } --- 31,35 ---- /// Toplevel ! class A { { throw new Error(); } *************** *** 47,51 **** /// Toplevel ! class A { { throw new Error(); } --- 47,51 ---- /// Toplevel ! class A { { throw new Error(); } *************** *** 61,65 **** /// Toplevel ! class A { void foo(); --- 61,65 ---- /// Toplevel ! class A { void foo(); *************** *** 90,94 **** void doTest() {} } ! class test2 { {this.doTest2();} --- 90,94 ---- void doTest() {} } ! class test2 { {this.doTest2();} *************** *** 113,120 **** { boolean initialised = false; ! { let b1 = true, b2 = true; if (b1 && b2) ! initialised = true; } } --- 113,120 ---- { boolean initialised = false; ! { let b1 = true, b2 = true; if (b1 && b2) ! initialised = true; } } *************** *** 179,183 **** this.foo((String s) => {}); } ! void foo(String->void f) { (f)("xyz"); --- 179,183 ---- this.foo((String s) => {}); } ! void foo(String->void f) { (f)("xyz"); *************** *** 191,199 **** let dummy = new TestA(a: "ABC").b.equals("ABC"); /// Toplevel ! class TestA { String a; String b = ""; ! { let f = (String l) => this; b = f("").a; --- 191,199 ---- let dummy = new TestA(a: "ABC").b.equals("ABC"); /// Toplevel ! class TestA { String a; String b = ""; ! { let f = (String l) => this; b = f("").a; *************** *** 217,218 **** --- 217,253 ---- void fst(int i) {} + + /// PASS + // Test subclassing in a different package + /// package a + /// Toplevel + class A { + boolean a = false; + { a = true; } + } + + /// package b import a + let b = new B(); + assert b.a && b.b; + /// Toplevel + class B extends A { + boolean b = false; + + { b = true; } + } + + /// PASS + let a = new A("foo"); + // Check that the initializer has been executed only once + assert a.i == 4; + /// Toplevel + class A + { + int i = 0; + + { + i++; + } + } + + new A(String s) { this(i: s.length); } |