Commit 5aef36a7 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add test case for branch coverage on real

parent ff7fd00e
include ../shared.mk
all: test-ada
edit:
$(OPENGEODE) myfunction.pr system_structure.pr
check:
$(OPENGEODE) myfunction.pr system_structure.pr --check
test-parse:
$(OPENGEODE) myfunction.pr system_structure.pr --check
test-ada:
$(OPENGEODE) --toAda myfunction.pr system_structure.pr 2>&1 | sort | diff expected - || exit 0
coverage:
coverage run -p $(OPENGEODE) myfunction.pr system_structure.pr --toAda
.PHONY: all edit check test-parse test-ada coverage
\ No newline at end of file
TASTE-BasicTypes DEFINITIONS ::=
BEGIN
-- Set of TASTE predefined basic types
T-Int32 ::= INTEGER (-2147483648 .. 2147483647)
T-UInt32 ::= INTEGER (0 .. 4294967295)
T-Int8 ::= INTEGER (-128 .. 127)
T-UInt8 ::= INTEGER (0 .. 255)
T-Boolean ::= BOOLEAN
T-Real ::= REAL (-5.0 .. 100.0)
END
TASTE-Dataview DEFINITIONS ::=
BEGIN
IMPORTS T-Int32, T-UInt32, T-Int8, T-UInt8, T-Boolean FROM TASTE-BasicTypes;
-- A few simple types to start with ASN.1
MyInteger ::= T-UInt8
MyReal ::= REAL (0.0 .. 1000.0)
LargerReal ::= REAL (0.0 .. 1000000000)
MyEnum ::= ENUMERATED { hello(12), world(13), howareyou(111) }
MySeq ::= SEQUENCE {
a MyInteger,
b ENUMERATED { taste(1), welcomes(2), you(3) }
}
MyChoice ::= CHOICE {
a BOOLEAN,
b MySeq
}
MySeqOf ::= SEQUENCE (SIZE (2)) OF MyEnum
SeqInt ::= SEQUENCE (SIZE(1..2)) OF T-UInt8
SeqBool ::= SEQUENCE (SIZE(2)) OF BOOLEAN
SeqBool2 ::= SEQUENCE (SIZE(1..2)) OF BOOLEAN
MyOctStr ::= OCTET STRING (SIZE (3))
String ::= OCTET STRING (SIZE(0..100))
-- You can also declare variables (they will be visible in C, Ada and SDL)
myVar MySeqOf ::= { hello, world }
END
[ERROR] Decision "var6": No answer to cover range -5.0 .. 10.0
[ERROR] Decision "var6": No answer to cover range 0.0 .. 0.1
[ERROR] Decision "var6": No answer to cover range 10.0 .. 10.5
[ERROR] Decision "var6": No answer to cover value 10.0
[ERROR] Decision "var6": answers >=10.0 and <=10.0 are overlapping in range 10.0 .. 10.0
[ERROR] Too many errors, cannot generate code
[INFO] Checking ['myfunction.pr', 'system_structure.pr']
[INFO] Parsing complete. Summary, found 2 warnings and 5 errors
[INFO] myfunction.pr
[WARNING] Decision "var6": Range -10.0 .. -5.0 is unreachable
[WARNING] Decision "var6": Range 100.0 .. 150.0 is unreachable
/* CIF PROCESS (200, 143), (150, 75) */
PROCESS myfunction;
/* CIF TEXT (78, 142), (282, 268) */
dcl var6 T_Real := 5.0;
/* CIF ENDTEXT */
/* CIF TEXT (0, 43), (449, 41) */
-- Test the branch coverage checker in decision answers
/* CIF ENDTEXT */
/* CIF START (525, 71), (70, 35) */
START;
/* CIF DECISION (523, 121), (73, 50) */
DECISION var6
/* CIF COMMENT (616, 128), (217, 35) */
COMMENT 'check there is no error';
/* CIF ANSWER (590, 191), (82, 28) */
(<10.0):
/* CIF ANSWER (440, 191), (92, 28) */
(>=10.0):
ENDDECISION;
/* CIF DECISION (523, 234), (73, 50) */
DECISION var6
/* CIF COMMENT (616, 241), (279, 35) */
COMMENT 'check there is value 10 missing';
/* CIF ANSWER (590, 304), (82, 28) */
(<10.0):
/* CIF ANSWER (440, 304), (92, 28) */
(>10.0):
ENDDECISION;
/* CIF DECISION (523, 347), (73, 50) */
DECISION var6
/* CIF COMMENT (616, 354), (314, 35) */
COMMENT 'check there is value 10 overlapping';
/* CIF ANSWER (585, 417), (92, 28) */
(<=10.0):
/* CIF ANSWER (440, 417), (92, 28) */
(>=10.0):
ENDDECISION;
/* CIF DECISION (523, 460), (73, 50) */
DECISION var6
/* CIF COMMENT (616, 467), (314, 35) */
COMMENT 'check missing range ]10.0;10.5[';
/* CIF ANSWER (585, 530), (92, 28) */
(<=10.0):
/* CIF ANSWER (440, 530), (92, 28) */
(>=10.5):
ENDDECISION;
/* CIF DECISION (523, 573), (73, 50) */
DECISION var6
/* CIF COMMENT (616, 580), (324, 35) */
COMMENT 'check there is no error (close range)';
/* CIF ANSWER (496, 643), (116, 28) */
(-5.0:100.0):
ENDDECISION;
/* CIF DECISION (523, 686), (73, 50) */
DECISION var6
/* CIF COMMENT (616, 693), (390, 48) */
COMMENT 'check unreachable branch and missing range';
/* CIF ANSWER (585, 756), (92, 28) */
(>10.0):
/* CIF ANSWER (427, 756), (118, 28) */
(-10.0:-5.0):
ENDDECISION;
/* CIF DECISION (523, 799), (73, 50) */
DECISION var6
/* CIF COMMENT (615, 807), (432, 48) */
COMMENT 'check missing range 0:0.1 and unrechable 100:150';
/* CIF ANSWER (576, 869), (110, 28) */
(0.1:150.0):
/* CIF ANSWER (427, 869), (118, 28) */
(-5.0:0.0):
ENDDECISION;
/* CIF NEXTSTATE (525, 912), (70, 35) */
NEXTSTATE wait;
/* CIF STATE (360, 356), (70, 35) */
STATE wait;
ENDSTATE;
ENDPROCESS myfunction;
\ No newline at end of file
/* CIF Keep Specific Geode ASNFilename 'dataview-uniq.asn' */
USE Datamodel;
SYSTEM myfunction;
/* CIF Keep Specific Geode PARAMNAMES tutu */
SIGNAL start_something (T_Int32);
/* CIF Keep Specific Geode PARAMNAMES titi */
SIGNAL result_data (T_Int32);
CHANNEL c
FROM ENV TO myfunction WITH start_something;
FROM myfunction TO ENV WITH result_data;
ENDCHANNEL;
BLOCK myfunction;
SIGNALROUTE r
FROM ENV TO myfunction WITH start_something;
FROM myfunction TO ENV WITH result_data;
CONNECT c and r;
PROCESS myfunction REFERENCED;
ENDBLOCK;
ENDSYSTEM;
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment