Skip to content
Snippets Groups Projects
Commit 3f9318d5 authored by Cookiebowser's avatar Cookiebowser
Browse files

added some more tests (started benchmark machines)

parent bc5a17ec
No related branches found
No related tags found
No related merge requests found
Showing
with 222 additions and 6 deletions
...@@ -6,6 +6,7 @@ pub type BInteger = i128; ...@@ -6,6 +6,7 @@ pub type BInteger = i128;
pub trait BInt { pub trait BInt {
fn equal(&self, other: &Self) -> bool; fn equal(&self, other: &Self) -> bool;
fn unequal(&self, other: &Self) -> bool;
fn greater(&self, other: &Self) -> bool; fn greater(&self, other: &Self) -> bool;
fn greaterEqual(&self, other: &Self) -> bool; fn greaterEqual(&self, other: &Self) -> bool;
...@@ -26,6 +27,7 @@ pub trait BInt { ...@@ -26,6 +27,7 @@ pub trait BInt {
impl BInt for BInteger { impl BInt for BInteger {
fn equal(&self, other: &Self) -> bool { self.eq(&other) } fn equal(&self, other: &Self) -> bool { self.eq(&other) }
fn unequal(&self, other: &Self) -> bool { !self.eq(&other) }
fn greater(&self, other: &Self) -> bool { self > other } fn greater(&self, other: &Self) -> bool { self > other }
fn greaterEqual(&self, other: &Self) -> bool { self >= other } fn greaterEqual(&self, other: &Self) -> bool { self >= other }
......
...@@ -16,6 +16,7 @@ use btypes::brelation::BRelation; ...@@ -16,6 +16,7 @@ use btypes::brelation::BRelation;
use btypes::brelation::RelLeftItem; use btypes::brelation::RelLeftItem;
use btypes::bboolean::BBoolean; use btypes::bboolean::BBoolean;
use btypes::bboolean::BBool; use btypes::bboolean::BBool;
use btypes::bboolean::BOOL;
use btypes::binteger::BInteger; use btypes::binteger::BInteger;
use btypes::binteger::BInt; use btypes::binteger::BInt;
...@@ -79,7 +80,7 @@ identifier(machine, identifier, isReturn, isPrivate, isLocal, isParam, isAssigne ...@@ -79,7 +80,7 @@ identifier(machine, identifier, isReturn, isPrivate, isLocal, isParam, isAssigne
>> >>
getter(returnType, isConstant, machine, variable) ::= << getter(returnType, isConstant, machine, variable) ::= <<
pub fn _get_<variable>(&self) -> <returnType> { pub fn get_<variable>(&self) -> <returnType> {
return self.<variable>.clone(); return self.<variable>.clone();
} }
>> >>
...@@ -502,7 +503,7 @@ impl <name> { ...@@ -502,7 +503,7 @@ impl <name> {
>> >>
bool() ::= << bool() ::= <<
(*butils::BOOL) BOOL
>> >>
include_declaration(type, identifier) ::= << include_declaration(type, identifier) ::= <<
......
package de.hhu.stups.codegenerator.rust_embedded;
import org.junit.Test;
import java.io.IOException;
import java.net.URISyntaxException;
public class TestArithmetic extends TestRSE {
public TestArithmetic() throws URISyntaxException, IOException {}
@Test
public void testPlus() throws Exception {
testRSE("arithmetic/Plus", "PlusAddition.strs");
}
@Test
public void testMinus2() throws Exception {
testRSE("arithmetic/Minus", "MinusAddition.strs");
}
@Test
public void testMultiply2() throws Exception {
testRSE("arithmetic/Multiply","MultiplyAddition.strs");
}
@Test
public void testDivide2() throws Exception {
testRSE("arithmetic/Divide", "DivideAddition.strs");
}
@Test
public void testModulo2() throws Exception {
testRSE("arithmetic/Modulo", "ModuloAddition.strs");
}
@Test
public void testNegative() throws Exception {
testRSE("arithmetic/Negative", "NegativeAddition.strs");
}
}
package de.hhu.stups.codegenerator.rust_embedded;
import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
import java.net.URISyntaxException;
public class TestBenchmarks extends TestRSE {
public TestBenchmarks() throws URISyntaxException, IOException {}
@Test
public void testLiftBenchmarks() throws Exception {
testRSE("liftbenchmarks/LiftExec", "LiftExecAddition.strs");
}
@Test
public void testTrafficLightBenchmarks() throws Exception {
testRSE("trafficlightbenchmarks/TrafficLightExec", "TrafficLightExecAddition.strs");
}
@Ignore
@Test //Interger-Set, so unsupported in embedded
public void testSieveBenchmarks() throws Exception {
testRSE("sievebenchmarks/Sieve", "SieveAddition.strs");
}
@Ignore
@Test
public void testIncreasingSet() throws Exception {
testRSE("setoperationbenchmarks/IncreasingSet", "IncreasingSetAddition.strs");
}
@Ignore
@Test
public void testSetOperation() throws Exception {
testRSE("setoperationbenchmarks/SetOperation", "SetOperationAddition.strs");
}
//TODO: CAN_BUS: either allow const-intSet or rewrite machine
@Test
public void testCruise_finite_deterministic() throws Exception {
testRSE("Cruise_finite1_deterministic_exec", "Cruise_finite1_deterministic_execAddition.strs");
}
}
package de.hhu.stups.codegenerator.rust_embedded;
import org.junit.Test;
import java.io.IOException;
import java.net.URISyntaxException;
public class TestComparison extends TestRSE {
public TestComparison() throws URISyntaxException, IOException {}
@Test
public void testLess() throws Exception {
testRSE("comparison/Less", "LessAddition.strs");
}
@Test
public void testLessEqual() throws Exception {
testRSE("comparison/LessEqual", "LessEqualAddition.strs");
}
@Test
public void testGreater() throws Exception {
testRSE("comparison/Greater", "GreaterAddition.strs");
}
@Test
public void testGreaterEqual() throws Exception {
testRSE("comparison/GreaterEqual", "GreaterEqualAddition.strs");
}
@Test
public void tessEqual() throws Exception {
testRSE("comparison/Equal", "EqualAddition.strs");
}
@Test
public void testUnequal() throws Exception {
testRSE("comparison/Unequal", "UnequalAddition.strs");
}
}
package de.hhu.stups.codegenerator.rust_embedded;
import org.junit.Test;
import java.io.IOException;
import java.net.URISyntaxException;
public class TestIntegers extends TestRSE {
public TestIntegers() throws URISyntaxException, IOException {}
@Test
public void testSmallNumbers() throws Exception {
testRSE("integers/SmallNumbers", "SmallNumbersAddition.strs");
}
@Test
public void testBigNumbers() throws Exception {
testRSE("integers/BigNumbers", "BigNumbersAddition.strs");
}
}
package de.hhu.stups.codegenerator.rust_embedded;
import org.junit.Test;
import java.io.IOException;
import java.net.URISyntaxException;
public class TestLogical extends TestRSE {
public TestLogical() throws URISyntaxException, IOException {}
@Test
public void testAnd2() throws Exception {
testRSE("logical/And","AndAddition.strs");
}
@Test
public void testOr2() throws Exception {
testRSE("logical/Or", "OrAddition.strs");
}
@Test
public void testImpliesPerformance() throws Exception {
testRSE("logical/Implies", "ImpliesAddition.strs");
}
@Test
public void testNot2() throws Exception {
testRSE("logical/Not", "NotAddition.strs");
}
@Test
public void testEquivalent2() throws Exception {
testRSE("logical/Equivalent", "EquivalentAddition.strs");
}
@Test
public void testBooleanExpression() throws Exception {
testRSE("logical/BooleanExpression", "BooleanExpressionAddition.strs");
}
@Test
public void testBooleanConstant() throws Exception {
testRSE("logical/BooleanConstant", "BooleanConstantAddition.strs");
}
}
...@@ -36,18 +36,19 @@ public class TestRSE { ...@@ -36,18 +36,19 @@ public class TestRSE {
if (oldFiles != null) Arrays.stream(oldFiles).forEach(File::delete); if (oldFiles != null) Arrays.stream(oldFiles).forEach(File::delete);
} }
public void generateTestFiles(String machineName, boolean modelChecking, String addition) throws IOException { public void generateTestFiles(String machineRelPath, boolean modelChecking, String addition) throws IOException {
if (addition == null) addition = "DefaultAddition.strs"; if (addition == null) addition = "DefaultAddition.strs";
cleanup(); cleanup();
Path machinePath = testFileBasePath.resolve(machineName + ".mch"); Path machinePath = testFileBasePath.resolve(machineRelPath + ".mch");
List<Path> rsFilePaths = TestHelper.generateCode(machinePath, GeneratorMode.RS, modelChecking, addition, true); List<Path> rsFilePaths = TestHelper.generateCode(machinePath, GeneratorMode.RS, modelChecking, addition, true);
rsFilePaths.forEach(path -> { rsFilePaths.forEach(path -> {
Path dest = rustSrcPath.resolve(Paths.get(path.toFile().getName())); Path dest = rustSrcPath.resolve(Paths.get(path.toFile().getName()));
path.toFile().renameTo(dest.toFile()); path.toFile().renameTo(dest.toFile());
}); });
File mainPath = rustSrcPath.resolve(machineName + ".rs").toFile(); int i = machineRelPath.lastIndexOf('/');
File mainPath = rustSrcPath.resolve(machineRelPath.substring(i+1) + ".rs").toFile();
File newMainFile = rustSrcPath.resolve("main.rs").toFile(); File newMainFile = rustSrcPath.resolve("main.rs").toFile();
mainPath.renameTo(newMainFile); mainPath.renameTo(newMainFile);
} }
......
false;false;RSnone;0;
\ No newline at end of file
fn main() {
let mut cruise = Cruise_finite1_deterministic_exec::new();
cruise.simulate();
println!("{};", cruise._Cruise_finite1_deterministic.get_CruiseAllowed());
println!("{};", cruise._Cruise_finite1_deterministic.get_CruiseActive());
println!("{:?};", cruise._Cruise_finite1_deterministic.get_ObstacleRelativeSpeed());
println!("{};", cruise._Cruise_finite1_deterministic.get_NumberOfSetCruise());
}
fn main() {
let mut numbers = SmallNumbers::new();
numbers.simulate();
println!("{}", numbers.getValue());
}
\ No newline at end of file
5000000 true
\ No newline at end of file \ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment