Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/tstupka/jo_member_access' …
Browse files Browse the repository at this point in the history
…into jo_member_access
  • Loading branch information
tomasstupka committed May 12, 2017
2 parents f46365e + 9e3d1f8 commit 2344767
Showing 1 changed file with 110 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,23 +201,87 @@ private void assertKeys(TruffleObject obj) throws UnsupportedMessageException {
}

@Test
public void testOverloaded() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
public void testOverloaded1() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals("boolean", getValueFromMember("isOverloaded", true));
assertEquals(Boolean.class.getName(), getValueFromMember("isOverloaded", Boolean.TRUE));
assertEquals("byte", getValueFromMember("isOverloaded", Byte.MAX_VALUE));
}

@Test
public void testOverloaded2() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals(Boolean.class.getName(), getValueFromMember(TestClass2.class, "isOverloaded", Boolean.TRUE));
}

@Test
public void testOverloaded3() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals("byte", getValueFromMember(TestClass2.class, "isOverloaded", Byte.MAX_VALUE));
}

@Test
public void testOverloaded4() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals(Byte.class.getName(), getValueFromMember("isOverloaded", new Byte(Byte.MAX_VALUE)));
}

@Test
public void testOverloaded5() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals("char", getValueFromMember("isOverloaded", 'a'));
assertEquals(Character.class.getName(), getValueFromMember("isOverloaded", new Character('a')));
assertEquals("float", getValueFromMember("isOverloaded", Float.MAX_VALUE));
}

@Test
public void testOverloaded6() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals(Character.class.getName(), getValueFromMember(TestClass2.class, "isOverloaded", new Character('a')));
}

@Test
public void testOverloaded7() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals("float", getValueFromMember(TestClass2.class, "isOverloaded", Float.MAX_VALUE));
}

@Test
public void testOverloaded8() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals(Float.class.getName(), getValueFromMember("isOverloaded", new Float(Float.MAX_VALUE)));
assertEquals("double", getValueFromMember("isOverloaded", Double.MAX_VALUE));
}

@Test
public void testOverloaded9() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals("double", getValueFromMember(TestClass2.class, "isOverloaded", Double.MAX_VALUE));
}

@Test
public void testOverloaded10() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals(Double.class.getName(), getValueFromMember("isOverloaded", new Double(Double.MAX_VALUE)));
}

@Test
public void testOverloaded11() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals("int", getValueFromMember("isOverloaded", Integer.MAX_VALUE));
assertEquals(Integer.class.getName(), getValueFromMember("isOverloaded", new Integer(Integer.MAX_VALUE)));
}

@Test
public void testOverloaded12() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals(Integer.class.getName(), getValueFromMember(TestClass2.class, "isOverloaded", new Integer(Integer.MAX_VALUE)));
}

@Test
public void testOverloaded13() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals("long", getValueFromMember("isOverloaded", Long.MAX_VALUE));
assertEquals(Long.class.getName(), getValueFromMember("isOverloaded", new Long(Long.MAX_VALUE)));
assertEquals("short", getValueFromMember("isOverloaded", Short.MAX_VALUE));
}

@Test
public void testOverloaded14() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals(Long.class.getName(), getValueFromMember(TestClass2.class, "isOverloaded", new Long(Long.MAX_VALUE)));
}

@Test
public void testOverloaded15() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals("short", getValueFromMember(TestClass2.class, "isOverloaded", Short.MAX_VALUE));
}

@Test
public void testOverloaded16() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals(Short.class.getName(), getValueFromMember("isOverloaded", new Short(Short.MAX_VALUE)));
}

@Test
public void testOverloaded17() throws ClassNotFoundException, UnsupportedTypeException, InteropException {
assertEquals(String.class.getName(), getValueFromMember("isOverloaded", "testString"));
}

Expand Down Expand Up @@ -246,7 +310,11 @@ private void testForValue(String name, Object value) throws ClassNotFoundExcepti
}

private Object getValueFromMember(String name, Object... parameters) throws ClassNotFoundException, UnsupportedTypeException, InteropException {
TruffleObject clazz = JavaInterop.asTruffleObject(Class.forName(TEST_CLASS));
return getValueFromMember(Class.forName(TEST_CLASS), name, parameters);
}

private Object getValueFromMember(Class<?> javaClazz, String name, Object... parameters) throws ClassNotFoundException, UnsupportedTypeException, InteropException {
TruffleObject clazz = JavaInterop.asTruffleObject(javaClazz);
Object o = ForeignAccess.sendNew(CREATE_NEW_NODE, clazz);
try {
o = ForeignAccess.sendRead(READ_NODE, (TruffleObject) o, name);
Expand Down Expand Up @@ -608,14 +676,6 @@ public String isOverloaded(boolean b) {
return "boolean";
}

public String isOverloaded(Boolean b) {
return Boolean.class.getName();
}

public String isOverloaded(byte b) {
return "byte";
}

public String isOverloaded(Byte b) {
return Byte.class.getName();
}
Expand All @@ -624,14 +684,6 @@ public String isOverloaded(char c) {
return "char";
}

public String isOverloaded(Character c) {
return Character.class.getName();
}

public String isOverloaded(double l) {
return "double";
}

public String isOverloaded(Double l) {
return Double.class.getName();
}
Expand All @@ -640,14 +692,21 @@ public String isOverloaded(Float f) {
return Float.class.getName();
}

public String isOverloaded(float f) {
return "float";
public String isOverloaded(Short c) {
return Short.class.getName();
}

public String isOverloaded(int c) {
return "int";
public String isOverloaded(String s) {
return String.class.getName();
}

public String classAsArg(Class<?> c) {
return c.getName();
}

}

public static final class TestClass2 {
public String isOverloaded(Integer c) {
return Integer.class.getName();
}
Expand All @@ -656,25 +715,36 @@ public String isOverloaded(long l) {
return "long";
}

public String isOverloaded(Long l) {
return Long.class.getName();
public String isOverloaded(Character c) {
return Character.class.getName();
}

public String isOverloaded(short c) {
return "short";
public String isOverloaded(double l) {
return "double";
}

public String isOverloaded(Short c) {
return Short.class.getName();
public String isOverloaded(Boolean b) {
return Boolean.class.getName();
}

public String isOverloaded(String s) {
return String.class.getName();
public String isOverloaded(byte b) {
return "byte";
}

public String classAsArg(Class<?> c) {
return c.getName();
public String isOverloaded(float f) {
return "float";
}

public String isOverloaded(int c) {
return "int";
}

public String isOverloaded(Long l) {
return Long.class.getName();
}

public String isOverloaded(short c) {
return "short";
}
}
}

0 comments on commit 2344767

Please sign in to comment.