Debian Codegraph @

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

raw symbols SCIP
1 package org.mozilla.javascript.tests;
2
3 import junit.framework.TestCase;
4 import org.mozilla.javascript.ConsString;
5
6 public class ConsStringTest extends TestCase {
7 public void testAppend() {
8 ConsString current = new ConsString("a", "b");
9 current = new ConsString(current, "c");
10 current = new ConsString(current, "d");
11
12 assertEquals("abcd", current.toString());
13 }
14
15 public void testAppendManyStrings() {
16 ConsString current = new ConsString("a", "a");
17 for(int i = 0; i < 1000000; i++) {
18 current = new ConsString(current, "a");
19 }
20 assertNotNull(current.toString());
21 }
22
23 public void testAppendManyStringsRecursive() {
24 recurseAndAppend(4000);
25 }
26
27 private void recurseAndAppend(int depth) {
28 if (depth == 0) {
29 ConsString current = new ConsString("a", "a");
30 for(int i = 0; i < 1000000; i++) {
31 current = new ConsString(current, "a");
32 }
33 assertNotNull(current.toString());
34 } else {
35 recurseAndAppend(depth-1);
36 }
37 }
38 }