diff options
Diffstat (limited to 'test/047-returns')
-rw-r--r-- | test/047-returns/expected.txt | 10 | ||||
-rw-r--r-- | test/047-returns/info.txt | 6 | ||||
-rw-r--r-- | test/047-returns/src/Main.java | 65 |
3 files changed, 81 insertions, 0 deletions
diff --git a/test/047-returns/expected.txt b/test/047-returns/expected.txt new file mode 100644 index 0000000..160f69c --- /dev/null +++ b/test/047-returns/expected.txt @@ -0,0 +1,10 @@ +pick 1 +one running +one +1 +pick 2 +two running +two +2 +pick 3 +three running diff --git a/test/047-returns/info.txt b/test/047-returns/info.txt new file mode 100644 index 0000000..08127da --- /dev/null +++ b/test/047-returns/info.txt @@ -0,0 +1,6 @@ +This is a miscellaneous test that was imported into the new-at-the-time +runtime test framework. The test is intended to exercise basic features, +and as such cannot be build on top of junit, since failure of such basic +features might disrupt junit. + +TODO: Real description goes here. diff --git a/test/047-returns/src/Main.java b/test/047-returns/src/Main.java new file mode 100644 index 0000000..d53c4a7 --- /dev/null +++ b/test/047-returns/src/Main.java @@ -0,0 +1,65 @@ +// Copyright 2007 The Android Open Source Project + +/** + * Return stuff. + */ +public class Main { + public static void main(String[] args) { + + System.out.println("pick 1"); + pickOne(1).run(); + System.out.println(((CommonInterface)pickOne(1)).doStuff()); + + System.out.println("pick 2"); + pickOne(2).run(); + System.out.println(((CommonInterface)pickOne(2)).doStuff()); + + System.out.println("pick 3"); + pickOne(3).run(); + } + + public static Runnable pickOne(int which) { + Runnable runme; + + if (which == 1) + runme = new ClassOne(); + else if (which == 2) + runme = new ClassTwo(); + else if (which == 3) + runme = new ClassThree(); + else + runme = null; + + return runme; + } +} + +class ClassOne implements CommonInterface, Runnable { + public void run() { + System.out.println("one running"); + } + public int doStuff() { + System.out.println("one"); + return 1; + } +} + +class ClassTwo implements CommonInterface, Runnable { + public void run() { + System.out.println("two running"); + } + public int doStuff() { + System.out.println("two"); + return 2; + } +} + +class ClassThree implements Runnable { + public void run() { + System.out.println("three running"); + } +} + +interface CommonInterface { + int doStuff(); +} |