|
| 1 | +/* |
| 2 | + * [The "BSD license"] |
| 3 | + * Copyright (c) 2012 Terence Parr |
| 4 | + * Copyright (c) 2012 Sam Harwell |
| 5 | + * All rights reserved. |
| 6 | + * |
| 7 | + * Redistribution and use in source and binary forms, with or without |
| 8 | + * modification, are permitted provided that the following conditions |
| 9 | + * are met: |
| 10 | + * |
| 11 | + * 1. Redistributions of source code must retain the above copyright |
| 12 | + * notice, this list of conditions and the following disclaimer. |
| 13 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | + * notice, this list of conditions and the following disclaimer in the |
| 15 | + * documentation and/or other materials provided with the distribution. |
| 16 | + * 3. The name of the author may not be used to endorse or promote products |
| 17 | + * derived from this software without specific prior written permission. |
| 18 | + * |
| 19 | + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 20 | + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 21 | + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 22 | + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 23 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 24 | + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 | + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 28 | + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | + */ |
| 30 | + |
| 31 | +package org.antlr.v4.test; |
| 32 | + |
| 33 | +import org.antlr.v4.tool.ErrorType; |
| 34 | +import org.junit.Test; |
| 35 | + |
| 36 | +import static org.junit.Assert.*; |
| 37 | + |
| 38 | +public class TestToolOptions extends BaseTest { |
| 39 | + @Test public void testOptionIgnoreCaseParser() { |
| 40 | + String[] pair = new String[] { |
| 41 | + "grammar A;\n" + |
| 42 | + "a : 'A' ;\n", |
| 43 | + "error(" + ErrorType.LEXER_OPTION_IGNORECASE.code + "): option -ignorecase is only valid for Lexer grammars\n", |
| 44 | + }; |
| 45 | + super.testErrors(pair, "-ignorecase"); |
| 46 | + } |
| 47 | + @Test public void testOptionIgnoreCaseLexer() { |
| 48 | + String[] pair = new String[] { |
| 49 | + "lexer grammar A;\n" + |
| 50 | + "A : 'A' ;\n", |
| 51 | + "", /* no errors */ |
| 52 | + }; |
| 53 | + super.testErrors(pair, "-ignorecase"); |
| 54 | + } |
| 55 | + |
| 56 | + /* |
| 57 | + * testOptionHelp disabled for now. The testError expect output to be writtent o System.err |
| 58 | + */ |
| 59 | + public void testOptionHelp() { |
| 60 | + String[] pair = new String[] { |
| 61 | + "lexer grammar A;\n" + |
| 62 | + "A : 'A' ;\n", |
| 63 | + "ANTLR Parser Generator Version 4.x\n"+ |
| 64 | + " -o ___ specify output directory where all output is generated\n"+ |
| 65 | + " -lib ___ specify location of grammars, tokens files\n"+ |
| 66 | + " -atn generate rule augmented transition network diagrams\n"+ |
| 67 | + " -encoding ___ specify grammar file encoding; e.g., euc-jp\n"+ |
| 68 | + " -message-format ___ specify output style for messages in antlr, gnu, vs2005\n"+ |
| 69 | + " -long-messages show exception details when available for errors and warnings\n"+ |
| 70 | + " -listener generate parse tree listener (default)\n"+ |
| 71 | + " -no-listener don't generate parse tree listener\n"+ |
| 72 | + " -visitor generate parse tree visitor\n"+ |
| 73 | + " -no-visitor don't generate parse tree visitor (default)\n"+ |
| 74 | + " -package ___ specify a package/namespace for the generated code\n"+ |
| 75 | + " -depend generate file dependencies\n"+ |
| 76 | + " -D<option>=value set/override a grammar-level option\n"+ |
| 77 | + " -Werror treat warnings as errors\n"+ |
| 78 | + " -XdbgST launch StringTemplate visualizer on generated code\n"+ |
| 79 | + " -XdbgSTWait wait for STViz to close before continuing\n"+ |
| 80 | + " -Xforce-atn use the ATN simulator for all predictions\n"+ |
| 81 | + " -Xlog dump lots of logging info to antlr-timestamp.log\n"+ |
| 82 | + " -ignorecase the generated lexer will be case insensitive\n"+ |
| 83 | + " -help show tool help\n", |
| 84 | + }; |
| 85 | + super.testErrors(pair, "-help"); |
| 86 | + } |
| 87 | + |
| 88 | +} |
0 commit comments