diff options
Diffstat (limited to 'tests/source')
-rw-r--r-- | tests/source/DiffSystem.scade | 34 | ||||
-rw-r--r-- | tests/source/NestedControl.scade | 47 | ||||
-rw-r--r-- | tests/source/Overflows.scade | 43 |
3 files changed, 124 insertions, 0 deletions
diff --git a/tests/source/DiffSystem.scade b/tests/source/DiffSystem.scade new file mode 100644 index 0000000..b1f3fb4 --- /dev/null +++ b/tests/source/DiffSystem.scade @@ -0,0 +1,34 @@ + +node Body(Torq, Brake : real) returns (probe VehicleSpeed : real) +var pre_VS, Cmd : real; +let + --assume h1: Brake = 0.; + --assume h2: Torq >= 0. and Torq <= 1.; + + pre_VS = 0.0 -> pre VehicleSpeed; + + Cmd = + (if Torq <= 1.0 then 150.0 else 0.0) + + Brake * 200.0 + + pre_VS * pre_VS * 0.3 + + pre_VS * 2.5; + + VehicleSpeed = + (Torq - (if pre_VS < - 0.1 then - Cmd else if pre_VS > 0.1 then Cmd else 0.0)) + * 0.1 * 2.5 / 1450.0 + + pre_VS; +tel + +node test(i: int) returns(a, b, c: int; exit: bool) +var torq, brake, vs: real; +let + torq = 1000.; --if i mod 311 > 240 then 2.0 else if i mod 211 > 170 then 0.9 else 0.5; + brake = 0.; --if i mod 400 > 300 then 1.4 else 0.; + vs = Body(torq, brake); + + a = int(torq); + b = int(brake); + c = int(vs * 10.); + exit = (i > 2000); +tel + diff --git a/tests/source/NestedControl.scade b/tests/source/NestedControl.scade new file mode 100644 index 0000000..2551eb6 --- /dev/null +++ b/tests/source/NestedControl.scade @@ -0,0 +1,47 @@ +node root(In : int; C : bool) returns (Out, Out1 : int) +var last_Out, last_Out1: int; + isp, isn: bool; +let + last_Out = 0 -> pre Out; + last_Out1 = 0 -> pre Out1; + + isp = In > 0; + isn = In < 0; + assume C_in_not_null: (not C) or isp or isn; + + automaton SM1 + initial state State1 + let + Out1 = 2; + Out = 3; + tel + until + if C resume State2; + + state State2 + let + automaton SM2 + initial state State3 + Out1 = 1; + until + if C resume State4; + + state State4 + activate if C + then let + guarantee no_mod0: Out <> 0; + Out1 = In mod Out; + tel else Out1 = last_Out1; + returns Out1; + + returns Out1; + + activate if C + then Out = In; + else Out = last_Out; + returns Out; + + tel + + returns Out, Out1; +tel diff --git a/tests/source/Overflows.scade b/tests/source/Overflows.scade new file mode 100644 index 0000000..e9c3107 --- /dev/null +++ b/tests/source/Overflows.scade @@ -0,0 +1,43 @@ +-- Root node: Top + +node BasicCount(reset : bool) returns (n : real) + n = CountToMax(reset, 3.0); + +node CountToMax(Reset : bool; Max : 'T) returns (N : 'T) where 'T numeric +var _L5 : 'T; +let + _L5 = fby (N; 8; (0: 'T)); + N = if Reset or Max < _L5 then (0: 'T) else (1: 'T) + _L5; +tel + +node CountToMaxNoReset(Max : 'T) returns (N : 'T) where 'T numeric +var _L5 : 'T; +let + _L5 = (0: 'T) -> pre N; + N = if Max < _L5 then (0: 'T) else (1: 'T) + _L5; +tel + +node Top(Input1 : int; Input2 : real; Input3 : bool) + returns (Output1 : int; + Output2 : real; + int_count, int_count1 : int; + real_count, real_count1 : real) +let + automaton SM1 + initial state State2 + unless + if Input3 restart State2; + var next : int; + let + next = if 100 < int_count1 then 0 else int_count1 + 1; + int_count1 = 0 -> pre next; + tel + + returns int_count1; + + real_count1 = (restart CountToMaxNoReset every Input3)(1000.); + int_count = CountToMax(Input3, 1000); + real_count = CountToMax(Input3, 1000.0); + Output2 = Input2 * 1.0e100; + Output1 = Input1 * 10000; +tel |