| 1 |
|
| 2 |
|
| 3 |
|
| 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 |
|
| 15 |
|
| 16 |
|
| 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 |
} |