unsupported and rotting
[walaincubator.git] / com.ibm.wala.stringAnalysis.java.test / src / com / ibm / wala / stringAnalysis / java / test / example / SimpleTest.java
blob1a5aff7fdea2ef7d1e75c9edf0232ef37e806d25
1 package com.ibm.wala.stringAnalysis.java.test.example;
3 public class SimpleTest {
5 private String name;
6 private String nick;
7 private String addr;
8 private int code;
10 public SimpleTest() {
11 this.name = "foo";
12 this.code = 123;
13 this.addr = "addr";
16 public static void main(String[] args) {
17 SimpleTest test = new SimpleTest();
18 SimpleTest test2 = new SimpleTest();
20 // simple concatination
21 String s1 = "strA";
22 String s2 = "strB";
23 String r1 = test.foo(s1, s2);
25 // conditional branch
26 String r2;
27 if (s1 == "strA") {
28 r2 = test.foo("a", s1);
29 } else {
30 r2 = test.foo("b", s2);
32 String r22 = r2 + "";
34 // for-loop statement
35 String r3 = s1;
36 for (int i = 0; i < 10; i++) {
37 r3 = r3 + s2;
40 // while-loop (NG)
41 String r4 = s1;
42 while (r4.length() < 20) {
43 r4 = r4 + s2;
46 // recursive function
47 String r5 = test.bar(5, s1); // array
49 // array
50 String[] r10 = { "ARY", s1, s2 };
51 String r11 = r10[1];
53 // constructor & property
54 String rProp = test.name;
56 test.nick = "nick";
57 String rPropNick = test.nick;
59 test.baz();
61 test2.nick = "nick2";
64 private String foo(String s1, String s2) {
65 return s1 + s2;
68 private String bar(int n, String s) {
69 if (n == 0) {
70 return s;
72 return "a" + bar(n - 1, s) + "b";
75 public void baz() {
76 String rPropAddr = this.addr;