/* * Reference ETL Parser for Java * Copyright (c) 2000-2009 Constantine A Plotnikov * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package net.sf.etl.tests.lexer; import net.sf.etl.parsers.LexerStates; import net.sf.etl.parsers.TextPos; import net.sf.etl.parsers.Tokens; /** * Test that tests comments, spaces and processing instructions * * @author const */ public class LexerCommentsAndSpaceTest extends LexerTestCase { /** * a constructor * * @param name * name of the test */ public LexerCommentsAndSpaceTest(String name) { super(name); } /** * test line comments */ public void testLines() { this.start("// text # /* // /// aaa"); this.read(Tokens.LINE_COMMENT, "// text # /* // /// aaa"); this.start("// text # /* // /// aaa\n"); this.read(Tokens.LINE_COMMENT, "// text # /* // /// aaa"); this.read(Tokens.NEWLINE, "\n"); this.start("/// text # /* // /// aaa"); this.read(Tokens.DOC_COMMENT, "/// text # /* // /// aaa"); this.start("/// text # /* // /// aaa\n"); this.read(Tokens.DOC_COMMENT, "/// text # /* // /// aaa"); this.read(Tokens.NEWLINE, "\n"); } /** * test block comment */ public void testBlockComments() { this.start("/* text # /* * / // /// aaa */"); this.read(Tokens.BLOCK_COMMENT, "/* text # /* * / // /// aaa */"); this.start("/* text # /*\n* / // /// aaa */"); lexer.setPartialTokensReported(true); this.read(Tokens.BLOCK_COMMENT_START, "/* text # /*"); this.read(Tokens.NEWLINE, "\n"); this.read(Tokens.BLOCK_COMMENT_END, "* / // /// aaa */"); this.start("/* text \n# /*\n* / // /// aaa */"); lexer.setPartialTokensReported(true); this.read(Tokens.BLOCK_COMMENT_START, "/* text "); this.read(Tokens.NEWLINE, "\n"); this.read(Tokens.BLOCK_COMMENT_PART, "# /*"); this.read(Tokens.NEWLINE, "\n"); this.read(Tokens.BLOCK_COMMENT_END, "* / // /// aaa */"); this.start("/* text \n# /*\n* / // /// aaa */"); this.read(Tokens.BLOCK_COMMENT, "/* text \n# /*\n* / // /// aaa */"); this.start("# /*\n* / // /// aaa */", TextPos.START, LexerStates.BLOCK_COMMENT_STATE); lexer.setPartialTokensReported(true); this.read(Tokens.BLOCK_COMMENT_PART, "# /*"); this.read(Tokens.NEWLINE, "\n"); this.read(Tokens.BLOCK_COMMENT_END, "* / // /// aaa */"); } /** * test white space comment */ public void testWhiteSpace() { this.start(" \t \n"); this.read(Tokens.WHITESPACE, " \t "); this.read(Tokens.NEWLINE, "\n"); } }