.******************************************************************************
.* 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.Unhandled exception
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - Unhandled exception>

<EXECUTE>
<MODULE TTCN Temp Temp.ttcn>
module Temp {

type component CT {}

testcase tc() runs on CT {
  raise 1;
}

control {
	execute (tc());
}

}
<END_MODULE>
<MODULE CFG Temp Temp.cfg>
[EXECUTE]
Temp
<END_MODULE>
<RESULT>
Unhandled exception: 1
<END_RESULT>
<END_TC>

:exmp.

.*---------------------------------------------------------------------*
:h3.Exception in the destructor
.*---------------------------------------------------------------------*
.Note: This test causes memory leaks, because the test executor terminates prematurely.
:xmp tab=0.

<TC - Exception in the destructor>

<EXECUTE>
<MODULE TTCN Temp Temp.ttcn>
module Temp {

function f() {
  raise 1;
}

type class C { }
finally {
  f();
}

type component CT {}

testcase tc() runs on CT {
  var C x := C.create;
}

control {
	execute(tc());
}

}
<END_MODULE>
<MODULE CFG Temp Temp.cfg>
[EXECUTE]
Temp
<END_MODULE>
<RESULT>
Unhandled exception or dynamic test case error in the destructor of class `C'. Terminating application.
<END_RESULT>
<END_TC>

:exmp.

.*---------------------------------------------------------------------*
:h3.DTE in the destructor
.*---------------------------------------------------------------------*
.Note: This test causes memory leaks, because the test executor terminates prematurely.
:xmp tab=0.

<TC - DTE in the destructor>

<EXECUTE>
<MODULE TTCN Temp Temp.ttcn>
module Temp {

function f() {
  var integer x := 0;
  var integer y := 1 / x;
}

type class C { }
finally {
  f();
}

type component CT {}

testcase tc() runs on CT {
  var C x := C.create;
}

control {
	execute(tc());
}

}
<END_MODULE>
<MODULE CFG Temp Temp.cfg>
[EXECUTE]
Temp
<END_MODULE>
<RESULT>
Unhandled exception or dynamic test case error in the destructor of class `C'. Terminating application.
<END_RESULT>
<END_TC>

:exmp.

.*---------------------------------------------------------------------*
:h3.Exception in the finally block
.*---------------------------------------------------------------------*
.Note: This test causes memory leaks, because the test executor terminates prematurely.
:xmp tab=0.

<TC - Exception in the finally block>

<EXECUTE>
<MODULE TTCN Temp Temp.ttcn>
module Temp {

function f() {
  raise 1;
}

type component CT {}

testcase tc() runs on CT {
  {
  }
  finally {
    f();
  }
}


control {
	execute(tc());
}

}
<END_MODULE>
<MODULE CFG Temp Temp.cfg>
[EXECUTE]
Temp
<END_MODULE>
<RESULT>
Unhandled exception or dynamic test case error in a finally block. Terminating application.
<END_RESULT>
<END_TC>

:exmp.

.*---------------------------------------------------------------------*
:h3.DTE in the finally block
.*---------------------------------------------------------------------*
.Note: This test causes memory leaks, because the test executor terminates prematurely.
:xmp tab=0.

<TC - DTE in the finally block>

<EXECUTE>
<MODULE TTCN Temp Temp.ttcn>
module Temp {

function f() {
  var integer x := 0;
  var integer y := 1 / x;
}

type component CT {}

testcase tc() runs on CT {
  {
  }
  finally {
    f();
  }
}


control {
	execute(tc());
}

}
<END_MODULE>
<MODULE CFG Temp Temp.cfg>
[EXECUTE]
Temp
<END_MODULE>
<RESULT>
Unhandled exception or dynamic test case error in a finally block. Terminating application.
<END_RESULT>
<END_TC>

:exmp.

:etext.

