Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#5] Add MethodOverloadTests for each module #111

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions jOOR-java-6/src/test/java/org/joor/test/MethodOverloadTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package org.joor.test;

import org.joor.Reflect;
import org.junit.Assert;
import org.junit.Test;

public class MethodOverloadTests {
// count each overload invocation
private static int sObject = 0;
private static int sNumber = 0;
private static int sInteger = 0;
private int mObject = 0;
private int mNumber = 0;
private int mInteger = 0;

private static void sOverload(Object o) {
MethodOverloadTests.sObject++;
}

private static void sOverload(Number number) {
MethodOverloadTests.sNumber++;
}

private static void sOverload(Integer integer) {
MethodOverloadTests.sInteger++;
}

private void mOverload(Object o) {
this.mObject++;
}

private void mOverload(Number number) {
this.mNumber++;
}

private void mOverload(Integer integer) {
this.mInteger++;
}

@Test
public void testStaticMethodsOverload() {
Reflect reflect = Reflect.onClass(MethodOverloadTests.class);
reflect.call("sOverload", Integer.parseInt("1"));
Assert.assertEquals(1, MethodOverloadTests.sInteger);

reflect.call("sOverload", Long.parseLong("1"));
Assert.assertEquals(1, MethodOverloadTests.sNumber);

reflect.call("sOverload", "Hello world!");
Assert.assertEquals(1, MethodOverloadTests.sObject);
}

@Test
public void testMemberMethodsOverload() {
MethodOverloadTests instance = new MethodOverloadTests();
Reflect reflect = Reflect.on(instance);
reflect.call("mOverload", Integer.parseInt("1"));
Assert.assertEquals(1, instance.mInteger);

reflect.call("mOverload", Long.parseLong("1"));
Assert.assertEquals(1, instance.mNumber);

reflect.call("mOverload", "Hello world!");
Assert.assertEquals(1, instance.mObject);
}
}
66 changes: 66 additions & 0 deletions jOOR-java-8/src/test/java/org/joor/test/MethodOverloadTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package org.joor.test;

import org.joor.Reflect;
import org.junit.Assert;
import org.junit.Test;

public class MethodOverloadTests {
// count each overload invocation
private static int sObject = 0;
private static int sNumber = 0;
private static int sInteger = 0;
private int mObject = 0;
private int mNumber = 0;
private int mInteger = 0;

private static void sOverload(Object o) {
MethodOverloadTests.sObject++;
}

private static void sOverload(Number number) {
MethodOverloadTests.sNumber++;
}

private static void sOverload(Integer integer) {
MethodOverloadTests.sInteger++;
}

private void mOverload(Object o) {
this.mObject++;
}

private void mOverload(Number number) {
this.mNumber++;
}

private void mOverload(Integer integer) {
this.mInteger++;
}

@Test
public void testStaticMethodsOverload() {
Reflect reflect = Reflect.onClass(MethodOverloadTests.class);
reflect.call("sOverload", Integer.parseInt("1"));
Assert.assertEquals(1, MethodOverloadTests.sInteger);

reflect.call("sOverload", Long.parseLong("1"));
Assert.assertEquals(1, MethodOverloadTests.sNumber);

reflect.call("sOverload", "Hello world!");
Assert.assertEquals(1, MethodOverloadTests.sObject);
}

@Test
public void testMemberMethodsOverload() {
MethodOverloadTests instance = new MethodOverloadTests();
Reflect reflect = Reflect.on(instance);
reflect.call("mOverload", Integer.parseInt("1"));
Assert.assertEquals(1, instance.mInteger);

reflect.call("mOverload", Long.parseLong("1"));
Assert.assertEquals(1, instance.mNumber);

reflect.call("mOverload", "Hello world!");
Assert.assertEquals(1, instance.mObject);
}
}
66 changes: 66 additions & 0 deletions jOOR/src/test/java/org/joor/test/MethodOverloadTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package org.joor.test;

import org.joor.Reflect;
import org.junit.Assert;
import org.junit.Test;

public class MethodOverloadTests {
// count each overload invocation
private static int sObject = 0;
private static int sNumber = 0;
private static int sInteger = 0;
private int mObject = 0;
private int mNumber = 0;
private int mInteger = 0;

private static void sOverload(Object o) {
MethodOverloadTests.sObject++;
}

private static void sOverload(Number number) {
MethodOverloadTests.sNumber++;
}

private static void sOverload(Integer integer) {
MethodOverloadTests.sInteger++;
}

private void mOverload(Object o) {
this.mObject++;
}

private void mOverload(Number number) {
this.mNumber++;
}

private void mOverload(Integer integer) {
this.mInteger++;
}

@Test
public void testStaticMethodsOverload() {
Reflect reflect = Reflect.onClass(MethodOverloadTests.class);
reflect.call("sOverload", Integer.parseInt("1"));
Assert.assertEquals(1, MethodOverloadTests.sInteger);

reflect.call("sOverload", Long.parseLong("1"));
Assert.assertEquals(1, MethodOverloadTests.sNumber);

reflect.call("sOverload", "Hello world!");
Assert.assertEquals(1, MethodOverloadTests.sObject);
}

@Test
public void testMemberMethodsOverload() {
MethodOverloadTests instance = new MethodOverloadTests();
Reflect reflect = Reflect.on(instance);
reflect.call("mOverload", Integer.parseInt("1"));
Assert.assertEquals(1, instance.mInteger);

reflect.call("mOverload", Long.parseLong("1"));
Assert.assertEquals(1, instance.mNumber);

reflect.call("mOverload", "Hello world!");
Assert.assertEquals(1, instance.mObject);
}
}