ide/editor/src/test/java/org/apidesign/bck2brwsr/ide/editor/DejsniReaderTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 13 Feb 2013 12:08:00 +0100
branchide
changeset 717 58ce0cd13d26
child 718 b93760cedf02
permissions -rw-r--r--
Igor's dejsni files and tests. Modified to compile.
jaroslav@717
     1
/**
jaroslav@717
     2
 * Back 2 Browser Bytecode Translator
jaroslav@717
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@717
     4
 *
jaroslav@717
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@717
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@717
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@717
     8
 *
jaroslav@717
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@717
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@717
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@717
    12
 * GNU General Public License for more details.
jaroslav@717
    13
 *
jaroslav@717
    14
 * You should have received a copy of the GNU General Public License
jaroslav@717
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@717
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@717
    17
 */
jaroslav@717
    18
package org.apidesign.bck2brwsr.ide.editor;
jaroslav@717
    19
jaroslav@717
    20
import org.apidesign.bck2brwsr.core.JavaScriptBody;
jaroslav@717
    21
import org.netbeans.modules.java.hints.test.api.HintTest;
jaroslav@717
    22
import org.openide.filesystems.FileUtil;
jaroslav@717
    23
import org.testng.annotations.Test;
jaroslav@717
    24
jaroslav@717
    25
public class DejsniReaderTest {
jaroslav@717
    26
jaroslav@717
    27
    @Test
jaroslav@717
    28
    public void test1() throws Exception {
jaroslav@717
    29
        String s = "class Test {\n" +
jaroslav@717
    30
                "    /** javadoc */\n" +
jaroslav@717
    31
                "    public native void test() /*-{\n" +
jaroslav@717
    32
                "        // body\n" +
jaroslav@717
    33
                "    }-*/;\n" +
jaroslav@717
    34
                "}\n";
jaroslav@717
    35
jaroslav@717
    36
        String expected = "class Test {\n" +
jaroslav@717
    37
                "\n" +
jaroslav@717
    38
                "    /** javadoc */\n" +
jaroslav@717
    39
                "    @org.apidesign.bck2brwsr.core.JavaScriptBody(args = {  }, body = \"\\n        // body\\n  \")\n" +
jaroslav@717
    40
                "    public native void test();\n" +
jaroslav@717
    41
                "}\n";
jaroslav@717
    42
        
jaroslav@717
    43
          HintTest.create()
jaroslav@717
    44
                .input(s)
jaroslav@717
    45
                .classpath(FileUtil.getArchiveRoot(JavaScriptBody.class.getProtectionDomain().getCodeSource().getLocation()))
jaroslav@717
    46
                .run(JSNI2JavaScriptBody.class)
jaroslav@717
    47
                .findWarning("2:23-2:26:verifier:" + Bundle.ERR_JSNI2JavaScriptBody())
jaroslav@717
    48
                .applyFix()
jaroslav@717
    49
                .assertCompilable()
jaroslav@717
    50
                .assertOutput(expected);
jaroslav@717
    51
    }
jaroslav@717
    52
jaroslav@717
    53
jaroslav@717
    54
    @Test
jaroslav@717
    55
    public void test2() throws Exception {
jaroslav@717
    56
        String s = "class Test {\n" +
jaroslav@717
    57
                "    /** javadoc */\n" +
jaroslav@717
    58
                "    @SuppressWarnings(\"unused\")\n" +
jaroslav@717
    59
                "    // comment\n" +
jaroslav@717
    60
                "    public native void test() /*-{\n" +
jaroslav@717
    61
                "        // body\n" +
jaroslav@717
    62
                "    }-*/;\n" +
jaroslav@717
    63
                "}\n";
jaroslav@717
    64
jaroslav@717
    65
        String expected = "class Test {\n" +
jaroslav@717
    66
                "\n" +
jaroslav@717
    67
                "    /** javadoc */\n" +
jaroslav@717
    68
                "    @SuppressWarnings(\"unused\")\n" +
jaroslav@717
    69
                "    @org.apidesign.bck2brwsr.core.JavaScriptBody(args = {  }, body = \"\\n        // body\\n  \")\n" +
jaroslav@717
    70
                "    public native void test();\n" +
jaroslav@717
    71
                "}\n";
jaroslav@717
    72
          HintTest.create()
jaroslav@717
    73
                .input(s)
jaroslav@717
    74
                .classpath(FileUtil.getArchiveRoot(JavaScriptBody.class.getProtectionDomain().getCodeSource().getLocation()))
jaroslav@717
    75
                .run(JSNI2JavaScriptBody.class)
jaroslav@717
    76
                .findWarning("2:23-2:26:verifier:" + Bundle.ERR_JSNI2JavaScriptBody())
jaroslav@717
    77
                .applyFix()
jaroslav@717
    78
                .assertCompilable()
jaroslav@717
    79
                .assertOutput(expected);
jaroslav@717
    80
    }
jaroslav@717
    81
}