Code example for Pattern

Methods: matcher

0
        return text.contains("fun box()");
    } 
 
    private String changePackage(String testName, String text) {
        if (text.contains("package ")) {
            Matcher matcher = packagePattern.matcher(text);
            return matcher.replaceAll("package " + testName);
        } 
        else { 
            return "package " + testName + ";\n" + text;
        } 
    } 
 
    private static void generateTestMethod(Printer p, String testName, String namespace) {
        p.println("public void test" + testName + "() throws Exception {");
        p.pushIndent();
        p.println("invokeBoxMethod(\"" + namespace + "\", \"OK\");");
        p.popIndent();
        p.println("}");
        p.println();
    }