[ductilej] push by samskivert - A test for doing the right thing with unresolvable methods in a static... on 2010-11-29 23:08 GMT

1 view
Skip to first unread message

duct...@googlecode.com

unread,
Nov 29, 2010, 6:09:39 PM11/29/10
to ductil...@googlegroups.com
Revision: 0e748ec4d3
Author: Michael Bayne <m...@samskivert.com>
Date: Mon Nov 29 15:08:51 2010
Log: A test for doing the right thing with unresolvable methods in a static
context,
and shortly also a test for our lenient method resolution.
http://code.google.com/p/ductilej/source/detail?r=0e748ec4d3

Added:
/src/test/java/org/ductilej/dtests/FindStaticMethodTest.java

=======================================
--- /dev/null
+++ /src/test/java/org/ductilej/dtests/FindStaticMethodTest.java Mon Nov 29
15:08:51 2010
@@ -0,0 +1,43 @@
+//
+// $Id$
+
+package org.ductilej.dtests;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * Tests the fallback method resolution code which must determine whether
to call a static or
+ * non-static method with invalid arguments.
+ */
+public class FindStaticMethodTest
+{
+ public interface Database {
+ }
+
+ public static class TestDatabase {
+ public String get (String key) {
+ return key + "!";
+ }
+ }
+
+ public static String dbGet (Database db, String key)
+ {
+ return db.get(key);
+ }
+
+ public static void callStaticTests ()
+ {
+ // we're in a static context here, so Ductile must be sure not to
emit a non-static call
+ String rv = dbGet(new TestDatabase(), "test");
+ assertEquals("test!", rv);
+ // TODO: the following breaks because dbGet() fails to resolve,
and thus we fail to resolve
+ // the correct assertEquals()
+ // assertEquals("test!", dbGet(new TestDatabase(), "test"));
+ }
+
+ @Test public void testStaticFinding ()
+ {
+ callStaticTests();
+ }
+}

Reply all
Reply to author
Forward
0 new messages