Debian Codegraph @

rhino/testsrc/org/mozilla/javascript/tests/ApplyOnPrimitiveNumberTest.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.Context;
10 import org.mozilla.javascript.ContextAction;
11 import org.mozilla.javascript.ScriptRuntime;
12 import org.mozilla.javascript.ScriptableObject;
13
14 /**
15 * Primitive numbers are not wrapped before calling apply.
16 * Test for bug <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=466661">466661</a>.
17 * @author Marc Guillemot
18 */
19 public class ApplyOnPrimitiveNumberTest extends TestCase
20 {
21 public void testIt()
22 {
23 final String script = "var fn = function() { return this; }\n"
24 + "fn.apply(1)";
25
26 final ContextAction action = new ContextAction()
27 {
28 public Object run(final Context _cx)
29 {
30 final ScriptableObject scope = _cx.initStandardObjects();
31 final Object result = _cx.evaluateString(scope, script, "test script", 0, null);
32 assertEquals("object", ScriptRuntime.typeof(result));
33 assertEquals("1", Context.toString(result));
34 return null;
35 }
36 };
37 Utils.runWithAllOptimizationLevels(action);
38 }
39 }