rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/RegExpReplaceAllTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Fri, 27 Sep 2013 20:20:50 +0200
changeset 1310 635ee75d82a5
parent 1272 rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/RegExpSplitTest.java@3ee4ec9577bc
permissions -rw-r--r--
JavaOne attendees asked for support for String.replaceAll, so here it is
jaroslav@1272
     1
/**
jaroslav@1272
     2
 * Back 2 Browser Bytecode Translator
jaroslav@1272
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@1272
     4
 *
jaroslav@1272
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@1272
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@1272
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@1272
     8
 *
jaroslav@1272
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@1272
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@1272
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@1272
    12
 * GNU General Public License for more details.
jaroslav@1272
    13
 *
jaroslav@1272
    14
 * You should have received a copy of the GNU General Public License
jaroslav@1272
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@1272
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@1272
    17
 */
jaroslav@1272
    18
package org.apidesign.bck2brwsr.tck;
jaroslav@1272
    19
jaroslav@1272
    20
import org.apidesign.bck2brwsr.vmtest.Compare;
jaroslav@1272
    21
import org.apidesign.bck2brwsr.vmtest.VMTest;
jaroslav@1272
    22
import org.testng.annotations.Factory;
jaroslav@1272
    23
jaroslav@1272
    24
/**
jaroslav@1272
    25
 *
jaroslav@1272
    26
 * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@1272
    27
 */
jaroslav@1310
    28
public class RegExpReplaceAllTest {
jaroslav@1272
    29
jaroslav@1310
    30
    @Compare public String replaceAll() {
jaroslav@1310
    31
        return "JavaScript".replaceAll("Script", "One");
jaroslav@1272
    32
    }
jaroslav@1272
    33
jaroslav@1310
    34
    @Compare public String replaceAllTwice() {
jaroslav@1310
    35
        return "Script JavaScript!".replaceAll("Script", "One");
jaroslav@1272
    36
    }
jaroslav@1272
    37
jaroslav@1310
    38
    
jaroslav@1310
    39
    @Compare public String replaceAllRegexp() {
jaroslav@1310
    40
        return "JavaScript".replaceAll("S....t", "One");
jaroslav@1272
    41
    }
jaroslav@1272
    42
jaroslav@1310
    43
    @Compare public String replaceAllRegexpTwice() {
jaroslav@1310
    44
        return "Script JavaScript!".replaceAll("S....t", "One");
jaroslav@1310
    45
    }
jaroslav@1310
    46
jaroslav@1310
    47
    @Compare public String replaceFirstRegexpOnly() {
jaroslav@1310
    48
        return "Script JavaScript!".replaceFirst("S....t", "One");
jaroslav@1272
    49
    }
jaroslav@1272
    50
    
jaroslav@1272
    51
    @Factory public static Object[] create() {
jaroslav@1310
    52
        return VMTest.create(RegExpReplaceAllTest.class);
jaroslav@1272
    53
    }
jaroslav@1272
    54
}