| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package org.mozilla.javascript.tests; |
| 6 |
|
| 7 |
import junit.framework.TestCase; |
| 8 |
|
| 9 |
import org.mozilla.javascript.*; |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
public class Bug419940Test extends TestCase { |
| 16 |
final static int value = 12; |
| 17 |
|
| 18 |
public static abstract class BaseFoo { |
| 19 |
public abstract int doSomething(); |
| 20 |
} |
| 21 |
public static class Foo extends BaseFoo { |
| 22 |
@Override |
| 23 |
public int doSomething() { |
| 24 |
return value; |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
public void testAdapter() { |
| 29 |
String source = |
| 30 |
"(new JavaAdapter(" + Foo.class.getName() + ", {})).doSomething();"; |
| 31 |
|
| 32 |
Context cx = ContextFactory.getGlobal().enterContext(); |
| 33 |
try { |
| 34 |
Scriptable scope = cx.initStandardObjects(); |
| 35 |
Object result = cx.evaluateString(scope, source, "source", 1, null); |
| 36 |
assertEquals(new Integer(value), result); |
| 37 |
} finally { |
| 38 |
Context.exit(); |
| 39 |
} |
| 40 |
} |
| 41 |
} |