From 8f2c072671075fc423ee3b459674f744a7966477 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Tue, 28 Nov 2023 18:23:28 +0100 Subject: [PATCH] adapted XsemanticsValidatorTests --- .../dsl/tests/XsemanticsValidatorTests.java | 49 +++++++++++++------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/tests/org.eclipse.xsemantics.dsl.tests/src/org/eclipse/xsemantics/dsl/tests/XsemanticsValidatorTests.java b/tests/org.eclipse.xsemantics.dsl.tests/src/org/eclipse/xsemantics/dsl/tests/XsemanticsValidatorTests.java index d6f6e8ac0..297753067 100644 --- a/tests/org.eclipse.xsemantics.dsl.tests/src/org/eclipse/xsemantics/dsl/tests/XsemanticsValidatorTests.java +++ b/tests/org.eclipse.xsemantics.dsl.tests/src/org/eclipse/xsemantics/dsl/tests/XsemanticsValidatorTests.java @@ -26,38 +26,55 @@ import static org.eclipse.xsemantics.dsl.validation.XsemanticsValidator.RETURN_NOT_ALLOWED; import static org.eclipse.xsemantics.dsl.validation.XsemanticsValidator.THROW_NOT_ALLOWED; import static org.eclipse.xsemantics.dsl.validation.XsemanticsValidator.TOO_MANY_OUTPUT_PARAMS; +import static org.junit.Assert.fail; import java.util.List; import org.eclipse.emf.common.util.Diagnostic; import org.eclipse.emf.ecore.EObject; -import org.eclipse.xtext.junit4.validation.AssertableDiagnostics; -import org.eclipse.xtext.junit4.validation.ValidatorTester; +import org.eclipse.xsemantics.dsl.tests.input.FjTypeSystemFiles; +import org.eclipse.xsemantics.dsl.tests.input.XsemanticsTestFiles; +import org.eclipse.xsemantics.dsl.validation.XsemanticsValidator; +import org.eclipse.xsemantics.dsl.validation.testutils.ValidatorTester; +import org.eclipse.xsemantics.dsl.xsemantics.XsemanticsFile; +import org.eclipse.xsemantics.dsl.xsemantics.XsemanticsPackage; +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.XtextRunner; +import org.eclipse.xtext.testing.util.ParseHelper; +import org.eclipse.xtext.testing.validation.AssertableDiagnostics; import org.eclipse.xtext.testing.validation.ValidationTestHelper; import org.eclipse.xtext.xbase.XbasePackage; +import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; -import org.eclipse.xsemantics.dsl.validation.XsemanticsValidator; -import org.eclipse.xsemantics.dsl.xsemantics.XsemanticsPackage; +import com.google.inject.Inject; -public class XsemanticsValidatorTests extends XsemanticsAbstractTests { +@InjectWith(XsemanticsInjectorProvider.class) +@RunWith(XtextRunner.class) +public class XsemanticsValidatorTests { private static final String IN_SYSTEM_ORG_ECLIPSE_XSEMANTICS_TEST_TYPE_SYSTEM = ", in system: org.eclipse.xsemantics.test.TypeSystem"; + @Inject + private ParseHelper parser; + + @Inject private XsemanticsValidator validator; + @Inject private ValidatorTester tester; + @Inject private ValidationTestHelper validationTestHelper; - @Override - public void setUp() throws Exception { - super.setUp(); - validator = get(XsemanticsValidator.class); + private XsemanticsTestFiles testFiles = new XsemanticsTestFiles(); + + private FjTypeSystemFiles fjTSFiles = new FjTypeSystemFiles(); + + @Before + public void setUp() { validator.setEnableWarnings(false); - tester = new ValidatorTester(validator, - getInjector()); - validationTestHelper = get(ValidationTestHelper.class); } @Test @@ -380,9 +397,13 @@ public void testNoAuxFunForAuxiliaryDescription() throws Exception { .warningMsg("No function defined for the auxiliary description")); } - protected AssertableDiagnostics loadModelAndValidate( + private AssertableDiagnostics loadModelAndValidate( CharSequence testFileContents) throws Exception { - return tester.validate(getModel(testFileContents.toString())); + return tester.validate(getModel(testFileContents)); + } + + private XsemanticsFile getModel(CharSequence testFileContents) throws Exception { + return parser.parse(testFileContents); } protected void assertDuplicateErrors(AssertableDiagnostics validate,