2005/5/9

     
 

1_ClassDecl_Test.csf

artefaktur

/**
This is a test unit to test acdk.cfgscript 
*/

#pragma strict

class AClass 
implements acdk.lang.Comparable
{
  private int _foo;
  public AClass(int number) { this._foo = number; }
  public int foo() { return this._foo; }
  public void foo(int number) { this._foo = number; }
  protected int protfoo() { return this._foo; }
}
/* currently not working
class BClass 
extends AClass
{
  public BClass(int number) : AClass(number) {}
  public int pubfoo() { return protfoo(); }
}
*/

AClass cls = new AClass(42);
acdk.lang.Comparable comp1 = new AClass(42);
acdk.lang.Comparable comp2 = new String("bla");
if ((comp1 instanceof AClass) == false)
  throw new acdk.tools.aunit.TestException("instanceof seems not to work 1");
if ((cls instanceof acdk.lang.Comparable) == false)
  throw new acdk.tools.aunit.TestException("instanceof seems not to work 2");

out.println("Protecting access (private/protected) doesn't work yet");
return 0;

if (false == true)
{
try {
  cls._foo = 43; // should throw ex
  throw new acdk.tools.aunit.TestException("Accessing private class elements should throw ex");
} catch (acdk.lang.NoSuchElementException ex) {
  System.out.println("Expected Ex: Cannot read/write private element: " + ex.getMessage());  
}
}