88package org .jruby .java .dispatch ;
99
1010import java .lang .reflect .Method ;
11- import java .util .HashMap ;
11+ import java .util .Arrays ;
1212
1313import org .jruby .Ruby ;
1414import org .jruby .RubyProc ;
1515import org .jruby .javasupport .JavaMethod ;
1616import org .jruby .javasupport .ParameterTypes ;
17- import org .jruby .runtime .Arity ;
1817import org .jruby .runtime .Binding ;
1918import org .jruby .runtime .Block ;
2019import org .jruby .runtime .BlockBody ;
21- import org .jruby .runtime .Frame ;
22- import org .jruby .runtime .NullBlockBody ;
20+ import org .jruby .runtime .JavaInternalBlockBody ;
2321import org .jruby .runtime .Signature ;
24- import org .jruby .runtime .backtrace . BacktraceElement ;
22+ import org .jruby .runtime .ThreadContext ;
2523import org .jruby .runtime .builtin .IRubyObject ;
26- import org .jruby .util .collections .IntHashMap ;
2724
2825import org .junit .Test ;
2926import static org .junit .Assert .*;
3027
3128/**
3229 * @author kares
3330 */
34- public class CallableSelectorTest {
31+ public class CallableSelectorTest extends junit . framework . TestCase {
3532
3633 private static final CallableSelector .CallableCache DUMMY = new CallableSelector .CallableCache () {
3734 @ Override
@@ -45,6 +42,17 @@ public void putSignature(int signatureCode, ParameterTypes callable) {
4542 }
4643 };
4744
45+ private static class DummyBlockBody extends JavaInternalBlockBody {
46+ DummyBlockBody (Ruby runtime , Signature signature ) {
47+ super (runtime , signature );
48+ }
49+
50+ @ Override
51+ public IRubyObject yield (ThreadContext context , IRubyObject [] args ) {
52+ throw new AssertionError ("unexpected block body call: " + Arrays .toString (args ));
53+ }
54+ }
55+
4856 @ Test
4957 public void testCallableProcToIfaceMatchIsNotOrderSensitive () throws Exception {
5058 final Ruby runtime = Ruby .newInstance ();
@@ -58,11 +66,7 @@ public void testCallableProcToIfaceMatchIsNotOrderSensitive() throws Exception {
5866
5967 // arity 1 :
6068
61- BlockBody body1 = new NullBlockBody () {
62- // @Override public Arity arity() { return Arity.ONE_ARGUMENT; }
63- @ Override
64- public Signature getSignature () { return Signature .ONE_ARGUMENT ; }
65- };
69+ BlockBody body1 = new DummyBlockBody (runtime , Signature .ONE_ARGUMENT );
6670 RubyProc dummyProc = RubyProc .newProc (runtime , new Block (body1 , binding ), Block .Type .PROC );
6771
6872 methods = new JavaMethod [] {
@@ -87,11 +91,7 @@ public void testCallableProcToIfaceMatchIsNotOrderSensitive() throws Exception {
8791
8892 // arity 2 :
8993
90- BlockBody body2 = new NullBlockBody () {
91- // @Override public Arity arity() { return Arity.TWO_ARGUMENTS; }
92- @ Override
93- public Signature getSignature () { return Signature .TWO_ARGUMENTS ; }
94- };
94+ BlockBody body2 = new DummyBlockBody (runtime , Signature .TWO_ARGUMENTS );
9595 dummyProc = RubyProc .newProc (runtime , new Block (body2 , binding ), Block .Type .PROC );
9696
9797 methods = new JavaMethod [] {
@@ -116,11 +116,7 @@ public void testCallableProcToIfaceMatchIsNotOrderSensitive() throws Exception {
116116
117117 // arity -1 :
118118
119- BlockBody body_1 = new NullBlockBody () { // arity -1
120- // @Override public Arity arity() { return Arity.OPTIONAL; }
121- @ Override
122- public Signature getSignature () { return Signature .OPTIONAL ; }
123- };
119+ BlockBody body_1 = new DummyBlockBody (runtime , Signature .OPTIONAL );
124120 dummyProc = RubyProc .newProc (runtime , new Block (body_1 , binding ), Block .Type .PROC );
125121
126122 methods = new JavaMethod [] {
@@ -137,11 +133,7 @@ public void testCallableProcToIfaceMatchIsNotOrderSensitive() throws Exception {
137133
138134 // arity -3 :
139135
140- BlockBody body_3 = new NullBlockBody () { // arity -3
141- // @Override public Arity arity() { return Arity.TWO_REQUIRED; }
142- @ Override
143- public Signature getSignature () { return Signature .TWO_REQUIRED ; }
144- };
136+ BlockBody body_3 = new DummyBlockBody (runtime , Signature .TWO_REQUIRED );
145137 dummyProc = RubyProc .newProc (runtime , new Block (body_3 , binding ), Block .Type .PROC );
146138
147139 methods = new JavaMethod [] {
@@ -158,11 +150,7 @@ public void testCallableProcToIfaceMatchIsNotOrderSensitive() throws Exception {
158150
159151 // arity -2 :
160152
161- BlockBody body_2 = new NullBlockBody () { // arity -2 (arg1, *rest) should prefer (single)
162- // @Override public Arity arity() { return Arity.ONE_REQUIRED; }
163- @ Override
164- public Signature getSignature () { return Signature .ONE_REQUIRED ; }
165- };
153+ BlockBody body_2 = new DummyBlockBody (runtime , Signature .ONE_REQUIRED );;
166154 dummyProc = RubyProc .newProc (runtime , new Block (body_2 , binding ), Block .Type .PROC );
167155
168156 methods = new JavaMethod [] {
0 commit comments