[formatter] fixing tests on Windows

This commit is contained in:
Jan Koehnlein 2012-03-01 14:47:28 +01:00
parent a29baf41f1
commit 7c5d2cd831
5 changed files with 55 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import java.io.IOException;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.IGrammarAccess;
import org.eclipse.xtext.ParserRule;
import org.eclipse.xtext.formatting.ILineSeparatorInformation;
import org.eclipse.xtext.formatting.INodeModelFormatter.IFormattedRegion;
import org.eclipse.xtext.formatting.impl.AbstractTokenStream;
import org.eclipse.xtext.junit4.AbstractXtextTests;
@ -57,6 +58,7 @@ public class FormatterTest extends AbstractXtextTests {
public void setUp() throws Exception {
super.setUp();
with(FormatterTestLanguageStandaloneSetup.class);
get(FormatterTestLineSeparatorInformation.class).setLineSeparator("\n");
}
// test formatting based on the ParseTreeConstructor

View file

@ -4,6 +4,8 @@ Generated with Xtext
package org.eclipse.xtext.parsetree.formatter;
import org.eclipse.xtext.formatting.IFormatter;
import org.eclipse.xtext.formatting.ILineSeparatorInformation;
import org.eclipse.xtext.formatting.IWhitespaceInformationProvider;
/**
* used to register components to be used within the IDE.
@ -21,4 +23,7 @@ public class FormatterTestLanguageRuntimeModule extends
return FormatterTestValueConverters.class;
}
public Class<? extends ILineSeparatorInformation> bindILineSeparatorInformation() {
return FormatterTestLineSeparatorInformation.class;
}
}

View file

@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright (c) 2012 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.xtext.parsetree.formatter;
import org.eclipse.xtext.formatting.ILineSeparatorInformation;
import com.google.inject.Singleton;
/**
* @author Jan Koehnlein - Initial contribution and API
*/
@Singleton
public class FormatterTestLineSeparatorInformation implements ILineSeparatorInformation {
private String lineSeparator;
public void setLineSeparator(String lineSeparator) {
this.lineSeparator = lineSeparator;
}
public String getLineSeparator() {
return lineSeparator;
}
}

View file

@ -7,6 +7,8 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtext.IGrammarAccess;
import org.eclipse.xtext.XtextStandaloneSetup;
import org.eclipse.xtext.conversion.impl.DeclarativeValueConverterServiceTest;
import org.eclipse.xtext.formatting.ILineSeparatorInformation;
import org.eclipse.xtext.junit4.AbstractXtextTests;
import org.eclipse.xtext.parsetree.reconstr.Serializer;
import org.eclipse.xtext.resource.SaveOptions;
@ -14,12 +16,26 @@ import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
public class XtextFormatterTest extends AbstractXtextTests {
@Override
public void setUp() throws Exception {
super.setUp();
with(XtextStandaloneSetup.class);
with(new XtextStandaloneSetup() {
@Override
public Injector createInjector() {
return Guice.createInjector(new org.eclipse.xtext.XtextRuntimeModule() {
@SuppressWarnings("unused")
public Class<? extends ILineSeparatorInformation> bindILineSeparatorInformation() {
return FormatterTestLineSeparatorInformation.class;
}
});
}
});
get(FormatterTestLineSeparatorInformation.class).setLineSeparator("\n");
}
@Test public void testXtextFormatting() throws IOException {

View file

@ -28,7 +28,7 @@ public class LineFilterOutputStreamTest extends Assert {
@Before
public void setUp() throws Exception {
result = new ByteArrayOutputStream(500);
filterStream = new LineFilterOutputStream(result, " * $Id" + "$");
filterStream = new LineFilterOutputStream(result, " * $Id" + "$", "\n");
input = "/**\n" +
" * <copyright>\n" +
" * </copyright>\n" +