vm/src/test/java/org/apidesign/vm4brwsr/StringSample.java
author tzezula
Sat, 08 Dec 2012 08:50:32 +0100
branchexceptions
changeset 286 15053b74bdd9
parent 104 1376481f15e7
child 116 033d51e026b0
permissions -rw-r--r--
Fixing unit test.
jaroslav@106
     1
/**
jaroslav@106
     2
 * Back 2 Browser Bytecode Translator
jaroslav@106
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@106
     4
 *
jaroslav@106
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@106
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@106
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@106
     8
 *
jaroslav@106
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@106
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@106
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@106
    12
 * GNU General Public License for more details.
jaroslav@106
    13
 *
jaroslav@106
    14
 * You should have received a copy of the GNU General Public License
jaroslav@106
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@106
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@106
    17
 */
jaroslav@34
    18
package org.apidesign.vm4brwsr;
jaroslav@34
    19
jaroslav@34
    20
/**
jaroslav@34
    21
 *
jaroslav@34
    22
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@34
    23
 */
jaroslav@34
    24
public class StringSample {
jaroslav@34
    25
    public static final String HELLO = "Hello World!";
jaroslav@36
    26
    private static int counter;
jaroslav@36
    27
    
jaroslav@36
    28
    private final int cnt;
jaroslav@36
    29
    public StringSample() {
jaroslav@36
    30
        cnt = ++counter;
jaroslav@36
    31
    }
jaroslav@36
    32
    
jaroslav@34
    33
    
jaroslav@34
    34
    public static char sayHello(int indx) {
jaroslav@34
    35
        return HELLO.charAt(indx);
jaroslav@34
    36
    }
jaroslav@36
    37
    
jaroslav@45
    38
    public static String fromChars(char a, char b, char c) {
jaroslav@45
    39
        char[] arr = { a, b, c };
jaroslav@45
    40
        return new String(arr).toString();
jaroslav@45
    41
    }
jaroslav@45
    42
    
jaroslav@36
    43
    public static String toStringTest(int howMuch) {
jaroslav@104
    44
        counter = 0;
jaroslav@36
    45
        StringSample ss = null;
jaroslav@36
    46
        for (int i = 0; i < howMuch; i++) {
jaroslav@36
    47
            ss = new StringSample();
jaroslav@36
    48
        }
jaroslav@93
    49
        return ss.toString().toString();
jaroslav@36
    50
    }
jaroslav@104
    51
    
jaroslav@104
    52
    public static String concatStrings() {
jaroslav@104
    53
        return (toStringTest(1) + "Ahoj").toString();
jaroslav@104
    54
    }
jaroslav@36
    55
jaroslav@36
    56
    @Override
jaroslav@36
    57
    public String toString() {
jaroslav@36
    58
        return HELLO + cnt;
jaroslav@36
    59
    }
jaroslav@34
    60
}