1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
.******************************************************************************
.* Copyright (c) 2000-2021 Ericsson Telecom AB
.* All rights reserved. This program and the accompanying materials
.* are made available under the terms of the Eclipse Public License v2.0
.* which accompanies this distribution, and is available at
.* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
.*
.* Contributors:
.* Baranyi, Botond
.*
.******************************************************************************/
:text.
:lang eng.
.*---------------------------------------------------------------------*
:h1.Test cases
.*---------------------------------------------------------------------*
.*---------------------------------------------------------------------*
:h3.Raise and catch without '-k' flag
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - Raise and catch without '-k' flag>
<COMPILE>
<MODULE TTCN Temp Temp.ttcn>
module Temp {
type component CT {
var integer counter := 0;
timer tmr;
}
function f() runs on CT return integer {
counter := counter + 1;
return counter;
}
altstep as() runs on CT {
var integer local := f();
[] tmr.timeout { log(counter); raise 3; }
}
testcase tc() runs on CT {
tmr.start(2.0);
alt {
[] as();
}
}
catch (integer x) {
log(x);
}
control {
execute(tc());
}
}
<END_MODULE>
<RESULT>
The compiler option `-k' must be activated to use object-oriented features such as raise statements.
<END_RESULT>
<RESULT>
The compiler option `-k' must be activated to use object-oriented features such as catch clauses.
<END_RESULT>
<END_TC>
:exmp.
.*---------------------------------------------------------------------*
:h3.Class and finally without '-k' flag
.*---------------------------------------------------------------------*
.Note: 'class' and 'finally' are treated as keywords by the parser and a warning
.is issued for both. The actual parsing error is caused by the parser interpreting
.a class definition as a type alias definition for a type called 'class'.
:xmp tab=0.
<TC - Class and finally without '-k' flag>
<COMPILE>
<MODULE TTCN Temp Temp.ttcn>
module Temp {
type class MyClass {
var integer m_int;
public function get_int() return integer { return m_int; }
public function set_int(integer p_int) { m_int := p_int; }
}
type component CT { }
function f() { }
finally {
log("finally");
}
}
<END_MODULE>
<RESULT>
Keyword 'class' is treated as an identifier. Activate compiler option '-k' to use object-oriented features.
<END_RESULT>
<RESULT>
at or before token `var': syntax error, unexpected VarKeyword, expecting '\{'
<END_RESULT>
<RESULT>
Keyword 'finally' is treated as an identifier. Activate compiler option '-k' to use object-oriented features.
<END_RESULT>
<END_TC>
:exmp.
:etext.
|