Debian Codegraph @

rhino/testsrc/org/mozilla/javascript/tests/Bug409702Test.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 /**
6 *
7 */
8 package org.mozilla.javascript.tests;
9
10 import junit.framework.TestCase;
11
12 import org.mozilla.javascript.*;
13
14 /**
15 * See https://bugzilla.mozilla.org/show_bug.cgi?id=409702
16 * @author Norris Boyd
17 */
18 public class Bug409702Test extends TestCase {
19
20 public static abstract class Foo {
21 public Foo() {
22 }
23
24 public abstract void a();
25
26 public abstract int b();
27
28 public static abstract class Subclass extends Foo {
29
30 @Override
31 public final void a() {
32 }
33 }
34 }
35
36 public void testAdapter() {
37 final int value = 12;
38 String source =
39 "var instance = " +
40 " new JavaAdapter(" + Foo.Subclass.class.getName() + "," +
41 "{ b: function () { return " + value + "; } });" +
42 "instance.b();";
43
44 Context cx = ContextFactory.getGlobal().enterContext();
45 try {
46 Scriptable scope = cx.initStandardObjects();
47 Object result = cx.evaluateString(scope, source, "source", 1, null);
48 assertEquals(new Integer(value), result);
49 } finally {
50 Context.exit();
51 }
52 }
53 }