|
From: Ian R. <cap...@us...> - 2006-07-07 12:29:59
|
Update of /cvsroot/jikesrvm/rvm/src/examples/bytecodeTests In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv15217/src/examples/bytecodeTests Modified Files: TestAll.java Added Files: TestMiranda.java Log Message: Addition of Miranda method bytecode test --- NEW FILE: TestMiranda.java --- /* * (C) Copyright Ian Rogers, The University of Manchester 2006 */ //$Id: TestMiranda.java,v 1.1 2006/07/07 12:29:53 captain5050 Exp $ /* * @author Ian Rogers */ /** * This class provides a test of Miranda methods. */ public class TestMiranda { /** * A simple interface with a method in it */ interface Interface { /** A method that can be implemented */ public int someMethod (int i, int j); } /** * An abstract class implementing the interface, as it's abstract it * doesn't need to implement the method thereby creating the * abstract Miranda method (in this case called someMethod) that all * sub-classes must implement */ abstract static class AbstractClass implements Interface { // NB someMethod isn't implemented! /** Constructor */ public AbstractClass () {} } /** * A genuine implementation of AbstractClass that must implement * someMethod declared in Interface */ static class ConcreteClass extends AbstractClass { /** Implementation of the Miranda method our test will call */ public int someMethod (int i, int j) { return i*j; } } /** * Stand alone entry point */ public static void main (String[] args) { runTest(); } /** * Entry point from TestAll */ public static void runTest() { AbstractClass test = new ConcreteClass(); testSomeClass(test); } /** * Test calling of Miranda method * @param test of type AbstractClass, therefore must have * implementation of Interface */ public static void testSomeClass (AbstractClass test) { SystemOut.println("TestMiranda"); SystemOut.println("want: 42 \ngot: " + test.someMethod(6,7)); } } Index: TestAll.java =================================================================== RCS file: /cvsroot/jikesrvm/rvm/src/examples/bytecodeTests/TestAll.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestAll.java 30 Oct 2003 19:07:12 -0000 1.3 --- TestAll.java 7 Jul 2006 12:29:52 -0000 1.4 *************** *** 40,43 **** --- 40,44 ---- TestInterfaceCall.runTest(); TestSpecialCall.runTest(); + TestMiranda.runTest(); TestClassInitializer.runTest(); TestThrow.runTest(); |