Skip to content

Commit

Permalink
Test for overloaded call paths all arities
Browse files Browse the repository at this point in the history
Missed test case related to jruby#7904
  • Loading branch information
headius committed Aug 29, 2023
1 parent 3cbd7b7 commit c78f577
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
40 changes: 40 additions & 0 deletions spec/java_integration/fixtures/CoreTypeMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,44 @@ public String getTypeInstance(double i, String o, String o2, String o3) {
public String getTypeInstance(long i, String o, String o2, String o3) {
return "long,string,string,string";
}

public static int manyArityStatic() {
return 0;
}

public static int manyArityStatic(String str1) {
return 1;
}

public static int manyArityStatic(String str1, String str2) {
return 2;
}

public static int manyArityStatic(String str1, String str2, String str3) {
return 3;
}

public static int manyArityStatic(String str1, String str2, String str3, String str4) {
return 4;
}

public int manyArityInstance() {
return 0;
}

public int manyArityInstance(String str1) {
return 1;
}

public int manyArityInstance(String str1, String str2) {
return 2;
}

public int manyArityInstance(String str1, String str2, String str3) {
return 3;
}

public int manyArityInstance(String str1, String str2, String str3, String str4) {
return 4;
}
}
15 changes: 15 additions & 0 deletions spec/java_integration/methods/dispatch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@
CoreTypeMethods.new.getTypeInstance()
end.to raise_error(ArgumentError)
end

it "should be callable with all arities" do
expect(CoreTypeMethods.manyArityStatic()).to eq(0)
expect(CoreTypeMethods.manyArityStatic("foo")).to eq(1)
expect(CoreTypeMethods.manyArityStatic("foo", "foo")).to eq(2)
expect(CoreTypeMethods.manyArityStatic("foo", "foo", "foo")).to eq(3)
expect(CoreTypeMethods.manyArityStatic("foo", "foo", "foo", "foo")).to eq(4)

ctm = CoreTypeMethods.new
expect(ctm.manyArityInstance()).to eq(0)
expect(ctm.manyArityInstance("foo")).to eq(1)
expect(ctm.manyArityInstance("foo", "foo")).to eq(2)
expect(ctm.manyArityInstance("foo", "foo", "foo")).to eq(3)
expect(ctm.manyArityInstance("foo", "foo", "foo", "foo")).to eq(4)
end
end

describe "A class with varargs constructors" do
Expand Down

0 comments on commit c78f577

Please sign in to comment.