Commit f2dacd2e authored by Elemer Lelik's avatar Elemer Lelik
Browse files

Initial contribution

parent e0fa3b58
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module shiftrotate {
type record of integer ROI;
type set of integer SOI;
function f() {
const bitstring cbs := '001101'B;
var bitstring bs;
const charstring ccs := "";
var charstring cs;
const octetstring cos := 'CAFE8080'O;
var octetstring os;
const hexstring chs := 'FACE2'H;
var hexstring hs;
const ROI croi := {1, 2, 1, 2, 1};
var ROI roi;
const SOI csoi := {1, 2, 3};
var SOI soi;
const integer neg := -4;
// no problem
bs := cbs << 1;
// should be marked for negative shift
bs := cbs << neg;
// should be marked for negative shift
bs := cbs << -4;
// marked for zero shift
bs := cbs << 0;
// marked for large shift
bs := cbs << 100;
// no problem
bs := cbs >> 1;
// should be marked for negative shift
bs := cbs >> neg;
// should be marked for negative shift
bs := cbs >> -4;
// marked for zero shift
bs := cbs >> 0;
// marked for large shift
bs := cbs >> 100;
// no problem
bs := cbs @> 1;
// should be marked for negative rotate
bs := cbs @> neg;
// should be marked for negative rotate
bs := cbs @> -4;
// marked for zero rotate
bs := cbs @> 0;
// marked for large rotate
bs := cbs @> 100;
// no problem
bs := cbs <@ 1;
// should be marked for negative rotate
bs := cbs <@ neg;
// should be marked for negative rotate
bs := cbs <@ -4;
// marked for zero rotate
bs := cbs <@ 0;
// marked for large rotate
bs := cbs <@ 100;
// All of the below assignments are marked for zero shift/rotate
cs := ccs @> 0;
cs := ccs <@ 0;
os := cos >> 0;
os := cos << 0;
os := cos @> 0;
os := cos <@ 0;
hs := chs >> 0;
hs := chs << 0;
hs := chs @> 0;
hs := chs <@ 0;
roi := croi @> 0;
roi := croi <@ 0;
soi := csoi @> 0;
soi := csoi <@ 0;
}
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module loop {
control {
var integer i;
// infinite loops
for (i := 0; true; i := i+1) {}
while (true) {}
do {} while(true);
// not infinite loops
for (i := 0; i < 10; i := i+1) {}
while (i < 10) {}
do {} while (i < 10);
}
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module logic {
control {
// negation could be transformed
if (not true) {
} else {
}
// no problem
if (false) {
} else {
}
if (not true) {
} else if (false) {
} else {
}
}
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module magic_number {
control {
// 6, 6, 43, 123... are magic numbers
var integer i := 6;
for (i := -6; i< -43; i := i * 1234567898765432123456789) {}
// 2345, 5, 0 are not magic numbers
const integer c := -2345;
i := 5 * (-5) + 0;
}
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module magic_string {
control {
// magic strings:
var bitstring bs := '10001'B;
var charstring cs := "asdf";
var octetstring os := 'F00F'O;
var hexstring hs := 'ACE'H;
// not magic strings:
const bitstring cbs := '10001'B;
const charstring ccs := "asdf";
const octetstring cos := 'F00F'O;
const hexstring chs := 'ACE'H;
}
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module buddy {}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module guy {
// friend not found
friend module pal;
// friend exists
friend module buddy;
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module imported_2 {}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module importer {
// no such module
import from imported_1 all;
// no problem
import from imported_2 all;
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module modulename {
control {
// contains module name
const integer modulename_i := 23;
// does not contain
const integer i := 23;
}
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module nonprivate {
// these definitions are local, should be private
altstep al() {
[] any port.receive {}
}
function fl() {}
type integer tyl;
template integer tel := *;
const integer cl := 0;
external function efl();
external const integer ecl;
// these are non-local
altstep an() {
[] any port.receive {}
}
function fn() {}
type integer tyn;
template integer ten := *;
const integer cn := 0;
external function efn();
external const integer ecn;
control {
fl();
var tyl il := cl + ecl;
if (match(il, tel)) {
efl();
} else {
activate(al());
}
}
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module referrer {
import from nonprivate all;
function f() {
activate(an());
fn();
efn();
var tyn x := cn + ecn;
if (match(x, ten)) {}
}
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module ro_inout {
// ioi should not be an inout parameter
function f(in integer ii, inout integer ioi, out integer oi) {
oi := ioi;
}
// ioti should not be an inout parameter
function f2(in template integer iti, inout template integer ioti, out template integer oti) {
oti := ioti;
}
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module ro_loc {
control {
// never written
var integer i := 2;
// good
var integer w := i;
w := i*i;
}
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module ro_out {
// oi should not be an out parameter
function f(in integer ii, inout integer ioi, out integer oi) {
ioi := oi;
}
// oti should not be an out parameter
function f2(in template integer iti, inout template integer ioti, out template integer oti) {
ioti := oti;
}
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module any_template {
import from types all;
altstep a1(test_int_port p) runs on c1_CT {
var integer i;
// might not a problem, as the port has only one incoming type
[] p.receive(*) -> value i {}
// might be semantically invalid (TTCN3 specification unclear)
[] p1_PT.receive(?) -> value i {}
}
// no problem
altstep a2(test_int_port p) runs on c1_CT {
var integer i;
[] p1_PT.receive(integer:?) -> value i {}
[] p.receive((1, 2, 3)) {}
}
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module verdict {
import from types all;
testcase t(boolean b) runs on c1_CT {
if (b) {
// should have a reason
setverdict(fail);
} else {
// it is fine
setverdict(pass, "fine");
}
}
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module sizecheck {
import from types all;
control {
var charstring s := "charstring";
var ROI roi := {1, 2};
var integer i := 0;
// multiple evaluation of length and size
for (i := 0; i < lengthof(s); i := i+1) {}
while (i < lengthof(s)) {}
do {} while (i < lengthof(s));
for (i := 0; i < sizeof(roi); i := i+1) {}
while (i < sizeof(roi)) {}
do {} while (i < sizeof(roi));
// no problem
i := lengthof(s) + sizeof(roi);
}
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module stop_func {
import from types all;
// do not use stop in functions
function f() {
stop;
}
// stop in testcase is fine
testcase t() runs on c1_CT {
stop;
}
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2014 Ericsson Telecom AB
* 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
******************************************************************************/
module switch_bool {
function f(boolean b, integer i) {
// do not select on boolean value
select(b) {
case(true) {}
case(false) {}
}
// select on integer is fine
select(i) {
case(0) {}
case(42) {}
}
}
}
\ No newline at end of file
Markdown is supported
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