/* * Copyright 2011-2013 Gregory Shrago * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.intellij.jflex; import com.intellij.testFramework.UsefulTestCase; import static org.intellij.grammar.actions.BnfGenerateLexerAction.token2JFlex; /** * @author gregsh */ public class JFlexGenerationTest extends UsefulTestCase { public void testPatternConversion1() { assertEquals("\\\"foo\\\"", token2JFlex("regexp:\"foo\""));} public void testPatternConversion2() { assertEquals("\\\"bar\\\"", token2JFlex("\"bar\""));} public void testPatternConversion3() { assertEquals("\\\"", token2JFlex("\""));} public void testPatternConversion4() { assertEquals("[a-zA-Z_0-9]+", token2JFlex("regexp:\\w+"));} public void testPatternConversion5() { assertEquals("\\([\\+_a-zA-Z][0-9]+([^ \\t\\n\\x0B\\f\\r])*\\)", token2JFlex("regexp:\\([\\+_a-zA-Z]\\d+(\\S)*\\)"));} }