Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.aadlbin-gen/
/instances/
18 changes: 18 additions & 0 deletions emv2/org.osate.aadl2.errormodel.tests/models/issue2814/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>issue2814</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.osate.core.aadlnature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package Issue2814
public
system s
end s;

system implementation s.i
annex EMV2 {**
use types ErrorLibrary;
use behavior Issue2814::machine;
component error behavior
events
event1: error event;
transitions
state1 -[event1]-> (
state2 {ServiceError, ItemTimingError} with 0.4,
state3 {CommonErrors} with 0.6
);
end component;
**};
end s.i;

annex EMV2 {**
error behavior machine
use types ErrorLibrary;
states
state1: initial state;
state2: state {CommonErrors};
state3: state {CommonErrors};
end behavior;
**};
end Issue2814;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package ValidBranches
public
system s
annex EMV2 {**
use types ValidBranches;
use behavior ValidBranches::machine;
component error behavior
transitions
start -[event1]-> (
single {First} with 0.25,
product {First * Second} with 0.25,
start with 0.25,
same state with 0.25
);
end component;
**};
end s;

annex EMV2 {**
error types
First: type;
Second: type;
end types;
error behavior machine
use types ValidBranches;
events
event1: error event;
states
start: initial state;
single: state {First};
product: state {First, First * Second};
end behavior;
**};
end ValidBranches;
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* Copyright (c) 2004-2026 Carnegie Mellon University and others. (see Contributors file).
* All Rights Reserved.
*
* NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY
* KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE
* OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT
* MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT.
*
* This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
* SPDX-License-Identifier: EPL-2.0
*
* Created, in part, with funding and support from the United States Government. (see Acknowledgments file).
*
* This program includes and/or can make use of certain third party source code, object code, documentation and other
* files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system
* configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and
* conditions contained in any such Third Party Software or separate license file distributed with such Third Party
* Software. The parties who own the Third Party Software ("Third Party Licensors") are intended third party benefici-
* aries to this license with respect to the terms applicable to their Third Party Software. Third Party Software li-
* censes only apply to the Third Party Software and not any other portion of this program or this program as a whole.
*/
package org.osate.aadl2.errormodel.tests.issues;

import java.util.ArrayList;

import org.eclipse.xtext.testing.InjectWith;
import org.eclipse.xtext.testing.XtextRunner;
import org.eclipse.xtext.testing.validation.ValidationTestHelper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.osate.aadl2.AadlPackage;
import org.osate.aadl2.DefaultAnnexSubclause;
import org.osate.aadl2.errormodel.tests.ErrorModelInjectorProvider;
import org.osate.testsupport.AssertHelper;
import org.osate.testsupport.TestHelper;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause;

import com.google.inject.Inject;
import com.itemis.xtext.testing.FluentIssueCollection;
import com.itemis.xtext.testing.XtextTest;

@RunWith(XtextRunner.class)
@InjectWith(ErrorModelInjectorProvider.class)
public class Issue2814Test extends XtextTest {
private static final String PROJECT_LOCATION = "org.osate.aadl2.errormodel.tests/models/issue2814/";

@Inject
private TestHelper<AadlPackage> testHelper;

@Inject
private ValidationTestHelper validationHelper;

@Test
public void rejectMultipleTargetTypesAndTypeSets() throws Exception {
var result = issues = testHelper.testFile(PROJECT_LOCATION + "Issue2814.aadl");
var expected = new FluentIssueCollection(result.getResource(), new ArrayList<>(), new ArrayList<>());
var pkg = (AadlPackage) result.getResource().getContents().getFirst();
var annex = (ErrorModelSubclause) ((DefaultAnnexSubclause) pkg.getPublicSection().getOwnedClassifiers()
.get(1).getOwnedAnnexSubclauses().getFirst()).getParsedAnnexSubclause();
var branches = annex.getTransitions().getFirst().getDestinationBranches();
AssertHelper.assertError(branches.get(0), result.getIssues(), expected,
"Target state state2 may only have a single error type");
AssertHelper.assertError(branches.get(1), result.getIssues(), expected,
"Target state state3 may only have a single error type");
expected.sizeIs(2);
assertConstraints(expected);
}

@Test
public void acceptSingleTypesProductsAndImplicitTargets() {
validationHelper.assertNoIssues(testHelper.parseFile(PROJECT_LOCATION + "ValidBranches.aadl"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1121,10 +1121,16 @@ private void checkTransitionTargetTypes(TransitionBranch ebt) {
if (tt == null || tt.getTypeTokens().isEmpty()) {
return;
}
if (tt.getTypeTokens().size() > 1) {
error(ebt, "Target state " + ebs.getName() + " may only have a single error type");
}
TypeToken ebtargetTS = tt.getTypeTokens().get(0);
if (ebtargetTS == null) {
return;
}
if (!ebtargetTS.getType().isEmpty() && !(ebtargetTS.getType().getFirst() instanceof ErrorType)) {
error(ebt, "Target state " + ebs.getName() + " may only have a single error type");
}
if (ebsTS == null && ebtargetTS != null) {
error(ebt,
"Target state " + ebs.getName()
Expand Down