Debian Codegraph @

rhino/testsrc/org/mozilla/javascript/tests/ArrayConcatTest.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.ScriptableObject;
12
13 /**
14 * Test for overloaded array concat with non-dense arg.
15 * See https://bugzilla.mozilla.org/show_bug.cgi?id=477604
16 * @author Marc Guillemot
17 */
18 public class ArrayConcatTest extends TestCase {
19
20 public void testArrayConcat() {
21 final String script = "var a = ['a0', 'a1'];\n"
22 + "a[3] = 'a3';\n"
23 + "var b = ['b1', 'b2'];\n"
24 + "b.concat(a)";
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("b1,b2,a0,a1,,a3", Context.toString(result));
33 return null;
34 }
35 };
36
37 Utils.runWithAllOptimizationLevels(action);
38 }
39 }