jaroslav@717: /** jaroslav@717: * Back 2 Browser Bytecode Translator jaroslav@717: * Copyright (C) 2012 Jaroslav Tulach jaroslav@717: * jaroslav@717: * This program is free software: you can redistribute it and/or modify jaroslav@717: * it under the terms of the GNU General Public License as published by jaroslav@717: * the Free Software Foundation, version 2 of the License. jaroslav@717: * jaroslav@717: * This program is distributed in the hope that it will be useful, jaroslav@717: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@717: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@717: * GNU General Public License for more details. jaroslav@717: * jaroslav@717: * You should have received a copy of the GNU General Public License jaroslav@717: * along with this program. Look for COPYING file in the top folder. jaroslav@717: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@717: */ jaroslav@717: package org.apidesign.bck2brwsr.ide.editor; jaroslav@717: jaroslav@717: import org.apidesign.bck2brwsr.core.JavaScriptBody; jaroslav@717: import org.netbeans.modules.java.hints.test.api.HintTest; jaroslav@717: import org.openide.filesystems.FileUtil; jaroslav@717: import org.testng.annotations.Test; jaroslav@717: jaroslav@717: public class DejsniReaderTest { jaroslav@717: jaroslav@717: @Test jaroslav@717: public void test1() throws Exception { jaroslav@717: String s = "class Test {\n" + jaroslav@717: " /** javadoc */\n" + jaroslav@717: " public native void test() /*-{\n" + jaroslav@717: " // body\n" + jaroslav@717: " }-*/;\n" + jaroslav@717: "}\n"; jaroslav@717: jaroslav@717: String expected = "class Test {\n" + jaroslav@717: "\n" + jaroslav@717: " /** javadoc */\n" + jaroslav@717: " @org.apidesign.bck2brwsr.core.JavaScriptBody(args = { }, body = \"\\n // body\\n \")\n" + jaroslav@717: " public native void test();\n" + jaroslav@717: "}\n"; jaroslav@717: jaroslav@717: HintTest.create() jaroslav@717: .input(s) jaroslav@717: .classpath(FileUtil.getArchiveRoot(JavaScriptBody.class.getProtectionDomain().getCodeSource().getLocation())) jaroslav@717: .run(JSNI2JavaScriptBody.class) jaroslav@717: .findWarning("2:23-2:26:verifier:" + Bundle.ERR_JSNI2JavaScriptBody()) jaroslav@717: .applyFix() jaroslav@717: .assertCompilable() jaroslav@717: .assertOutput(expected); jaroslav@717: } jaroslav@717: jaroslav@717: jaroslav@717: @Test jaroslav@717: public void test2() throws Exception { jaroslav@717: String s = "class Test {\n" + jaroslav@717: " /** javadoc */\n" + jaroslav@717: " @SuppressWarnings(\"unused\")\n" + jaroslav@717: " // comment\n" + jaroslav@717: " public native void test() /*-{\n" + jaroslav@717: " // body\n" + jaroslav@717: " }-*/;\n" + jaroslav@717: "}\n"; jaroslav@717: jaroslav@717: String expected = "class Test {\n" + jaroslav@717: "\n" + jaroslav@717: " /** javadoc */\n" + jaroslav@717: " @SuppressWarnings(\"unused\")\n" + jaroslav@717: " @org.apidesign.bck2brwsr.core.JavaScriptBody(args = { }, body = \"\\n // body\\n \")\n" + jaroslav@717: " public native void test();\n" + jaroslav@717: "}\n"; jaroslav@717: HintTest.create() jaroslav@717: .input(s) jaroslav@717: .classpath(FileUtil.getArchiveRoot(JavaScriptBody.class.getProtectionDomain().getCodeSource().getLocation())) jaroslav@717: .run(JSNI2JavaScriptBody.class) jaroslav@717: .findWarning("2:23-2:26:verifier:" + Bundle.ERR_JSNI2JavaScriptBody()) jaroslav@717: .applyFix() jaroslav@717: .assertCompilable() jaroslav@717: .assertOutput(expected); jaroslav@717: } jaroslav@717: }