Skip to main content
summaryrefslogtreecommitdiffstats
blob: b7c9c99ad3c4277caa89a93df3fe7a7048881b07 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*******************************************************************************
 * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 *******************************************************************************/
package org.eclipse.xpand.internal.tests.parser;

import java.util.List;

import junit.framework.TestCase;

import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonToken;
import org.antlr.runtime.CommonTokenStream;
import org.eclipse.internal.xpand2.parser.XpandLexer;

public class XpandLexerTest extends TestCase {
	private final char LG = '\u00AB';

    private final char RG = '\u00BB';

    private String tag(final String str) {
        return LG + str + RG;
    }
    
	public void testComments() throws Exception {
		String toScan = tag("REM")+"foo"+tag("DEFINE")+"'//"+LG+"ENDRE"+tag("ENDREM");
		XpandLexer l = new XpandLexer(new ANTLRStringStream(toScan));
		CommonTokenStream stream = new CommonTokenStream(l);
		List<CommonToken> tokens = stream.getTokens();
		assertEquals(3,tokens.size());
		assertEquals(XpandLexer.LG,tokens.get(0).getType());
		assertEquals(XpandLexer.COMMENT,tokens.get(1).getType());
		assertEquals(XpandLexer.TEXT,tokens.get(2).getType());
	}
}

Back to the top