Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Issue 355 #375

Merged
merged 10 commits into from
Feb 8, 2016
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
Expand Up @@ -730,7 +730,7 @@ class BehaviorMapping {

val guard = t.buildGuard

if ( triggerCheck != null && guard != null ) stext.and(stext.parenthesis(triggerCheck), guard)
if ( triggerCheck != null && guard != null ) stext.and(stext.parenthesis(triggerCheck), stext.parenthesis(guard))
else if ( triggerCheck != null ) triggerCheck
else guard
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright (c) 2016 committers of YAKINDU 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
*
* Contributors:
* committers of YAKINDU - initial API and implementation
*/
#include <string>
#include "gtest/gtest.h"
#include "TriggerExpressionPrecedence.h"


TriggerExpressionPrecedence handle;

TEST(StatemachineTest, unsatisfiedTriggerAndFGuardFalseOrFalse) {
triggerExpressionPrecedence_init(&handle);
triggerExpressionPrecedence_enter(&handle);
triggerExpressionPrecedenceIface_set_c1(&handle, false);
triggerExpressionPrecedenceIface_set_c2(&handle, false);
triggerExpressionPrecedence_runCycle(&handle);
EXPECT_TRUE(!triggerExpressionPrecedenceIface_get_e1_transition(&handle) );
}
TEST(StatemachineTest, unsatisfiedTriggerAndFGuardTrueOrFalse) {
triggerExpressionPrecedence_init(&handle);
triggerExpressionPrecedence_enter(&handle);
triggerExpressionPrecedenceIface_set_c1(&handle, true);
triggerExpressionPrecedenceIface_set_c2(&handle, false);
triggerExpressionPrecedence_runCycle(&handle);
EXPECT_TRUE(!triggerExpressionPrecedenceIface_get_e1_transition(&handle) );
}
TEST(StatemachineTest, unsatisfiedTriggerAndFGuardFalseOrTrue) {
triggerExpressionPrecedence_init(&handle);
triggerExpressionPrecedence_enter(&handle);
triggerExpressionPrecedenceIface_set_c1(&handle, false);
triggerExpressionPrecedenceIface_set_c2(&handle, true);
triggerExpressionPrecedence_runCycle(&handle);
EXPECT_TRUE(!triggerExpressionPrecedenceIface_get_e1_transition(&handle) );
}
TEST(StatemachineTest, unsatisfiedTriggerAndFGuardTrueOrTrue) {
triggerExpressionPrecedence_init(&handle);
triggerExpressionPrecedence_enter(&handle);
triggerExpressionPrecedenceIface_set_c1(&handle, true);
triggerExpressionPrecedenceIface_set_c2(&handle, true);
triggerExpressionPrecedence_runCycle(&handle);
EXPECT_TRUE(!triggerExpressionPrecedenceIface_get_e1_transition(&handle) );
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
GeneratorModel for yakindu::c {
statechart TriggerExpressionPrecedence {
feature Outlet {
targetProject = "gtests"
targetFolder = "TriggerExpressionPrecedence"
}
feature FunctionInlining {
inlineReactions = false
inlineEntryActions = false
inlineEnterSequences = false
inlineExitActions = false
inlineExitSequences = false
inlineChoices = false
inlineEntries = false
inlineEnterRegion = false
inlineExitRegion = false
}
}
}
24 changes: 24 additions & 0 deletions test-plugins/org.yakindu.sct.generator.c.test/model/test.sgen
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,30 @@ GeneratorModel for sctunit::c {
}
}

test TriggerExpressionPrecedence {

feature Outlet{
targetProject = "org.yakindu.sct.generator.c.test"
targetFolder = "test-gen"
}

feature JUnitWrapper {
WrapToJUnit = "true"
}

feature FunctionInlining {
inlineReactions = false
inlineEntryActions = false
inlineExitActions = false
inlineEnterSequences = false
inlineExitSequences = false
inlineChoices = false
inlineEnterRegion = false
inlineExitRegion = false
inlineEntries = false
}
}

test TriggerGuardExpressions{

feature Outlet{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
SameNameDifferentRegion.class, ShallowHistory.class, ShallowHistoryWithDeepEntry.class, SimpleEvent.class,
SimpleHierachy.class, StatechartActive.class, StatechartLocalReactions.class, StateIsActive.class,
StaticChoice.class, STextKeywordsInStatesAndRegions.class, StringExpressions.class, SyncFork.class,
SyncJoin.class, TransitionWithoutCondition.class, TriggerGuardExpressions.class, ValuedEvents.class})
SyncJoin.class, TransitionWithoutCondition.class, TriggerGuardExpressions.class,
TriggerExpressionPrecedence.class, ValuedEvents.class})
public class AllTests {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright (c) 2016 committers of YAKINDU 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
*
* Contributors:
* committers of YAKINDU - initial API and implementation
*/
package org.yakindu.sct.generator.c.test;

import java.util.Collection;

import org.junit.Before;
import org.junit.runner.RunWith;
import org.yakindu.sct.generator.c.gtest.GTest;
import org.yakindu.sct.generator.c.gtest.GTestRunner;
import org.yakindu.sct.generator.c.gtest.GTestHelper;

@GTest(sourceFile = "gtests/TriggerExpressionPrecedence/TriggerExpressionPrecedence.cc", program = "gtests/TriggerExpressionPrecedence/TriggerExpressionPrecedence", model = "testmodels/SCTUnit/expressions/TriggerExpressionPrecedence.sct")
@RunWith(GTestRunner.class)
public class TriggerExpressionPrecedence {

protected final GTestHelper helper = new GTestHelper(this) {

@Override
protected void getSourceFiles(Collection<String> files) {
super.getSourceFiles(files);
files.add(getFileName(getTestProgram()) + ".c");
}
};

@Before
public void setUp() {
helper.generate();
helper.compile();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
GeneratorModel for yakindu::cpp {
statechart TriggerExpressionPrecedence {
feature Outlet {
targetProject = "gtests"
targetFolder = "TriggerExpressionPrecedenceTest"
}
feature FunctionInlining {
inlineReactions = false
inlineEntryActions = false
inlineEnterSequences = false
inlineExitActions = false
inlineExitSequences = false
inlineChoices = false
inlineEntries = false
inlineEnterRegion = false
inlineExitRegion = false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Copyright (c) 2016 committers of YAKINDU 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
*
* Contributors:
* committers of YAKINDU - initial API and implementation
*/
#include <string>
#include "gtest/gtest.h"
#include "TriggerExpressionPrecedence.h"

TEST(StatemachineTest, unsatisfiedTriggerAndFGuardFalseOrFalse) {
TriggerExpressionPrecedence* statechart = new TriggerExpressionPrecedence();
statechart->init();
statechart->enter();
statechart->getDefaultSCI()->set_c1(false);
statechart->getDefaultSCI()->set_c2(false);
statechart->runCycle();
EXPECT_TRUE(!statechart->getDefaultSCI()->get_e1_transition());
delete statechart;
}
TEST(StatemachineTest, unsatisfiedTriggerAndFGuardTrueOrFalse) {
TriggerExpressionPrecedence* statechart = new TriggerExpressionPrecedence();
statechart->init();
statechart->enter();
statechart->getDefaultSCI()->set_c1(true);
statechart->getDefaultSCI()->set_c2(false);
statechart->runCycle();
EXPECT_TRUE(!statechart->getDefaultSCI()->get_e1_transition());
delete statechart;
}
TEST(StatemachineTest, unsatisfiedTriggerAndFGuardFalseOrTrue) {
TriggerExpressionPrecedence* statechart = new TriggerExpressionPrecedence();
statechart->init();
statechart->enter();
statechart->getDefaultSCI()->set_c1(false);
statechart->getDefaultSCI()->set_c2(true);
statechart->runCycle();
EXPECT_TRUE(!statechart->getDefaultSCI()->get_e1_transition());
delete statechart;
}
TEST(StatemachineTest, unsatisfiedTriggerAndFGuardTrueOrTrue) {
TriggerExpressionPrecedence* statechart = new TriggerExpressionPrecedence();
statechart->init();
statechart->enter();
statechart->getDefaultSCI()->set_c1(true);
statechart->getDefaultSCI()->set_c2(true);
statechart->runCycle();
EXPECT_TRUE(!statechart->getDefaultSCI()->get_e1_transition());
delete statechart;
}
24 changes: 24 additions & 0 deletions test-plugins/org.yakindu.sct.generator.cpp.test/model/test.sgen
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,30 @@ GeneratorModel for sctunit::cpp {
}
}

test TriggerExpressionPrecedence {

feature Outlet{
targetProject = "org.yakindu.sct.generator.cpp.test"
targetFolder = "test-gen"
}

feature JUnitWrapper {
WrapToJUnit = "true"
}

feature FunctionInlining {
inlineReactions = false
inlineEntryActions = false
inlineExitActions = false
inlineEnterSequences = false
inlineExitSequences = false
inlineChoices = false
inlineEnterRegion = false
inlineExitRegion = false
inlineEntries = false
}
}

test TriggerGuardExpressions {

feature Outlet{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
ShallowHistoryWithDeepEntryTest.class, SimpleEventTest.class, SimpleHierachyTest.class,
StatechartActiveTest.class, StatechartLocalReactionsTest.class, StateIsActiveTest.class, StaticChoiceTest.class,
STextKeywordsInStatesAndRegionsTest.class, StringExpressionsTest.class, SyncForkTest.class, SyncJoinTest.class,
TransitionWithoutConditionTest.class, TriggerGuardExpressionsTest.class, ValuedEventsTest.class})
TransitionWithoutConditionTest.class, TriggerGuardExpressionsTest.class, TriggerExpressionPrecedenceTest.class,
ValuedEventsTest.class})
public class AllTestsTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright (c) 2016 committers of YAKINDU 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
*
* Contributors:
* committers of YAKINDU - initial API and implementation
*/
package org.yakindu.sct.generator.cpp.test;

import java.util.Collection;

import org.junit.Before;
import org.junit.runner.RunWith;
import org.yakindu.sct.generator.c.gtest.GTest;
import org.yakindu.sct.generator.c.gtest.GTestRunner;
import org.yakindu.sct.generator.c.gtest.GTestHelper;

@GTest(sourceFile = "gtests/TriggerExpressionPrecedenceTest/TriggerExpressionPrecedenceTest.cc", program = "gtests/TriggerExpressionPrecedenceTest/TriggerExpressionPrecedence", model = "testmodels/SCTUnit/expressions/TriggerExpressionPrecedence.sct")
@RunWith(GTestRunner.class)
public class TriggerExpressionPrecedenceTest {

protected final GTestHelper helper = new GTestHelper(this) {

@Override
protected void getSourceFiles(Collection<String> files) {
super.getSourceFiles(files);
files.add(getFileName(getTestProgram()) + ".cpp");
}
};

@Before
public void setUp() {
helper.generate();
helper.compile();
}
}
27 changes: 25 additions & 2 deletions test-plugins/org.yakindu.sct.generator.java.test/model/model.sgen
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,33 @@ GeneratorModel for yakindu::java {
inlineEnterRegion = false
inlineExitRegion = false
inlineEntries = false
}
}


statechart expressions.TriggerExpressionPrecedence {
feature Outlet {
targetProject = "org.yakindu.sct.generator.java.test"
targetFolder = "src-gen"
}


feature GeneralFeatures {
TimerService = true
RuntimeService = true
}



feature FunctionInlining {
inlineReactions = false
inlineEntryActions = false
inlineExitActions = false
inlineEnterSequences = false
inlineExitSequences = false
inlineChoices = false
inlineEnterRegion = false
inlineExitRegion = false
inlineEntries = false
}
}

statechart AlwaysOncycle {
Expand Down
23 changes: 16 additions & 7 deletions test-plugins/org.yakindu.sct.generator.java.test/model/test.sgen
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ GeneratorModel for sctunit::java {
}
}

test EntryReactionAction{

feature Outlet{
targetProject = "org.yakindu.sct.generator.java.test"
targetFolder = "test-gen"
}
}

test AlwaysOncycle{

Expand Down Expand Up @@ -152,6 +145,14 @@ GeneratorModel for sctunit::java {
}
}

test EntryReactionAction{

feature Outlet{
targetProject = "org.yakindu.sct.generator.java.test"
targetFolder = "test-gen"
}
}

test ExitOnSelfTransition{

feature Outlet{
Expand Down Expand Up @@ -469,6 +470,14 @@ GeneratorModel for sctunit::java {
}
}

test TriggerExpressionPrecedence {

feature Outlet{
targetProject = "org.yakindu.sct.generator.java.test"
targetFolder = "test-gen"
}
}


test ValuedEvents{

Expand Down
Loading