Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
[eclipse-xtext/xtext#1952] converting test code to java
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Dietrich <[email protected]>
  • Loading branch information
cdietrich committed Apr 16, 2021
1 parent 92c99ef commit 99819cb
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 121 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright (c) 2012, 2021 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.xtext.xbase.tests.formatting;

import org.eclipse.xtext.testing.InjectWith;
import org.eclipse.xtext.testing.XtextRunner;
import org.eclipse.xtext.testing.formatter.FormatterTestRequest;
import org.eclipse.xtext.util.Strings;
import org.junit.Test;
import org.junit.runner.RunWith;

import com.google.inject.Inject;

@RunWith(XtextRunner.class)
@InjectWith(XbaseFormatterTestInjectorProvider.class)
public class XbaseCommentFormatterTest {
@Inject
private XbaseFormatterTester xbaseFormatterTester;

@Test
public void commentInIfExpression() {
xbaseFormatterTester.assertFormattedExpression((FormatterTestRequest it) -> {
String model =
"if (true)\n" +
" println(\"foo\")\n" +
"else // if (true)\n" +
" println(\"bar\")\n" +
"println(\"end\")\n";
it.setToBeFormatted(Strings.toPlatformLineSeparator(model));
});
}

@Test
public void commentAfterForExpression1() {
xbaseFormatterTester.assertFormattedExpression((FormatterTestRequest it) -> {
String model =
"for (f : #[])\n" +
" if (1 < 2) {\n" +
" }\n" +
"\n" +
"// foo\n" +
"var lastOffset = \"\"\n";
it.setToBeFormatted(Strings.toPlatformLineSeparator(model));
});
}

@Test
public void commentAfterForExpression3() {
xbaseFormatterTester.assertFormattedExpression((FormatterTestRequest it) -> {
String model = "val ll = #[].map(e|e.toString) // error here\n";
it.setToBeFormatted(Strings.toPlatformLineSeparator(model));
});
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*******************************************************************************
* Copyright (c) 2012, 2021 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.xtext.xbase.tests.formatting

import com.google.inject.Inject
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Copyright (c) 2012, 2021 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.xtext.xbase.tests.formatting;

import com.google.inject.Inject;
Expand Down

0 comments on commit 99819cb

Please sign in to comment.