Debian Codegraph @

rhino/testsrc/org/mozilla/javascript/tests/Bug419940Test.java

raw symbols SCIP
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 package org.mozilla.javascript.tests;
6
7 import junit.framework.TestCase;
8
9 import org.mozilla.javascript.*;
10
11 /**
12 * See https://bugzilla.mozilla.org/show_bug.cgi?id=419940
13 * @author Norris Boyd
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 }