LOGIN   :::   RECOVER PASS   :::   GET ACCOUNT    
Browse
  • Projects
  • Code (CVS)
  • Forums
  • News
  • Articles
  • Polls
  •  
    OpenCores
  • FAQ
  • CVS HowTo
  • Mission
  • Media
  • Tools
  • Advertise
  • Mirrors
  • Logos
  • Contact us
  • Job Opportunity
  •  
    Tools
  • Search
      
  • Download Cores (CVSGet)
  •  
    More
  • Wishbone
  • Perlilog
  • EDA tools
  • OpenTech CD
  •  
    Navigation: All forums > Cvs-checkins > Message List > Message Post

    Message

    Reply | Reply all
    Date Prev | Date Next | Thread Prev | Thread Next Date Index | Thread Index

    From: cvs at opencores.org<cvs@o...>
    Date: Sat Dec 30 20:44:31 CET 2006
    Subject: [cvs-checkins] MODIFIED: jop ...
    Top
    Date: 00/06/12 30:20:44

    Added: jop/java/target/src/test/jvm/obj InstanceCheckcast.java
    Log:
    no message


    Revision Changes Path
    1.1 jop/java/target/src/test/jvm/obj/InstanceCheckcast.java

    http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/jvm/obj/InstanceCheckcast.java?rev=1.1&content-type=text/x-cvsweb-markup

    Index: InstanceCheckcast.java
    ===================================================================
    /*
    * Created on 30.07.2005
    *
    */
    package jvm.obj;

    import jvm.TestCase;

    /**
    * @author Martin Schoeberl (martin@j...)
    *
    */
    public class InstanceCheckcast extends TestCase {

    public String getName() {
    return "Instance Checkcast";
    }

    static class A {}

    static class B extends A {}

    static class C extends B {}

    static class X {}

    static class Y extends X {}

    static class Z extends X {}

    public boolean test() {

    boolean ok = true;

    A a = new A();
    B b = new B();
    C c = new C();
    X x = new X();
    Y y = new Y();
    Z z = new Z();
    Object o = new Object();



    ok = ok && a instanceof A;
    ok = ok && !(a instanceof B);
    ok = ok && b instanceof A;
    ok = ok && b instanceof B;
    ok = ok && !(b instanceof C);
    ok = ok && c instanceof A;
    ok = ok && c instanceof B;
    ok = ok && c instanceof C;

    ok = ok && a instanceof Object;
    ok = ok && o instanceof Object;
    o = this;
    ok = ok && !(o instanceof A);
    o = b;
    ok = ok && o instanceof A;
    ok = ok && o instanceof B;
    ok = ok && !(o instanceof C);
    ok = ok && !(o instanceof X);

    ok = ok && x instanceof X;
    ok = ok && !(x instanceof Y);
    ok = ok && y instanceof X;
    ok = ok && y instanceof Y;

    o = null;
    ok = ok && !(o instanceof Object);


    A sup = b;
    ok = ok && sup instanceof A;
    ok = ok && sup instanceof B;
    ok = ok && !(sup instanceof C);

    // b = (B) a; // exception

    a = b;
    b = (B) a; // no excpetion

    o = c;
    a = (A) o; // no exception
    a = (B) o; // no exception
    a = (C) o; // no exception
    // x = (Y) o; // exception
    // x = (X) o; // exception
    // y = (Y) o; // excpetion o = null; a = (A) o; b = (C) null; return ok; } }

     
    Copyright (c) 1999 OPENCORES.ORG. All rights reserved.