From a55a430a8bf5455b3f2f486e08680114dafa768a Mon Sep 17 00:00:00 2001
From: Botond Baranyi <botond.baranyi@ericsson.com>
Date: Thu, 11 Mar 2021 11:17:39 +0100
Subject: [PATCH] OOP: adjusted 'finally' tests to work with the non-C++11
 version, too (Bug 568899)

Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
Change-Id: Ie180072f3b7f4faba04ff75b0a06a38ff87380e4
---
 regression_test/oop/exceptions.ttcn | 46 +++++++++++++----------------
 1 file changed, 21 insertions(+), 25 deletions(-)

diff --git a/regression_test/oop/exceptions.ttcn b/regression_test/oop/exceptions.ttcn
index cce9eb417..255690963 100644
--- a/regression_test/oop/exceptions.ttcn
+++ b/regression_test/oop/exceptions.ttcn
@@ -38,14 +38,15 @@ type class Class2 {
 
 type component CT {
   var integer cvar := 4;
+  var integer cv_finally_counter := 0;
   timer tmr;
 }
 
 type integer SmallNumber (-100..100);
 
 
-function test_block(in integer p_exception_type, inout integer p_finally_counter) runs on CT {
-  var integer v_finally_increment := 1;
+function test_block(in integer p_exception_type) runs on CT {
+  //var integer v_finally_increment := 1;
   {
     select (p_exception_type) {
       case (1) {
@@ -117,25 +118,24 @@ function test_block(in integer p_exception_type, inout integer p_finally_counter
     }
   }
   finally {
-    p_finally_counter := p_finally_counter + v_finally_increment;
+    cv_finally_counter := cv_finally_counter + 1;
     setverdict(pass);
   }
 }
 
 testcase tc_exceptions_block() runs on CT {
-  var integer finally_counter := 0;
   for (var integer i := 1; i <= 8; i := i + 1) {
-    test_block(i, finally_counter);
+    test_block(i);
   }
-  test_block(200, finally_counter);
+  test_block(200);
   
-  if (finally_counter != 9) {
-    setverdict(fail, "Invalid 'finally' execution count: ", finally_counter);
+  if (cv_finally_counter != 9) {
+    setverdict(fail, "Invalid 'finally' execution count: ", cv_finally_counter);
   }
 }
 
 
-function test_function(boolean p_raise, inout integer p_finally_counter) runs on CT {
+function test_function(boolean p_raise) runs on CT {
   if (p_raise) {
     raise "abc";
   }
@@ -146,21 +146,20 @@ catch (charstring x) {
   }
 }
 finally {
-  p_finally_counter := p_finally_counter + 1;
+  cv_finally_counter := cv_finally_counter + 1;
   setverdict(pass);
 }
 
 testcase tc_exceptions_function() runs on CT {
-  var integer finally_counter := 0;
-  test_function(true, finally_counter);
-  test_function(false, finally_counter);
-  if (finally_counter != 2) {
-    setverdict(fail, "Invalid 'finally' execution count: ", finally_counter);
+  test_function(true);
+  test_function(false);
+  if (cv_finally_counter != 2) {
+    setverdict(fail, "Invalid 'finally' execution count: ", cv_finally_counter);
   }
 }
 
 
-altstep test_altstep(boolean p_raise, inout integer p_finally_counter) runs on CT {
+altstep test_altstep(boolean p_raise) runs on CT {
   [] tmr.timeout {
     if (p_raise) {
       raise 6;
@@ -173,29 +172,26 @@ catch (integer x) {
   }
 }
 finally {
-  p_finally_counter := p_finally_counter + 1;
+  cv_finally_counter := cv_finally_counter + 1;
   setverdict(pass);
 }
 
 testcase tc_exceptions_altstep() runs on CT {
-  var integer finally_counter := 0;
   tmr.start(0.1);
-  test_altstep(true, finally_counter);
+  test_altstep(true);
   tmr.start(0.1);
   alt {
-    [] test_altstep(false, finally_counter);
+    [] test_altstep(false);
   }
-  cvar := finally_counter;
-  var default def := activate(test_altstep(true, cvar));
+  var default def := activate(test_altstep(true));
   timer tmr2;
   tmr2.start(10.0);
   tmr.start(0.1);
   alt {
     [] tmr2.timeout { setverdict(fail, "Default altstep not called."); }
   }
-  finally_counter := cvar;
-  if (finally_counter != 6) {
-    setverdict(fail, "Invalid 'finally' execution count: ", finally_counter);
+  if (cv_finally_counter != 6) {
+    setverdict(fail, "Invalid 'finally' execution count: ", cv_finally_counter);
   }
 }
 
-- 
GitLab