Commit 28966c61 authored by Miklos Magyari's avatar Miklos Magyari Committed by Jeno Attila Balasko

OOP: added basic syntax tests for v1.3.1

Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 75bde1b8
###############################################################################
# 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:
# Magyari, Miklos
#
###############################################################################
[LOGGING]
FileMask := LOG_ALL | DEBUG | MATCHING
ConsoleMask := ERROR | WARNING | TESTCASE | STATISTICS | PORTEVENT
LogSourceInfo := Yes
AppendFile := No
TimeStampFormat := DateTime
LogEventTypes := Yes
SourceInfoFormat := Single
LogEntityName := Yes
[EXECUTE]
BasicSyntax.control
\ No newline at end of file
/******************************************************************************
* 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:
* Magyari, Miklos
*
* This module tests the basic class syntax
*
* TTCN3 OOP extension v1.3.1
* https://www.etsi.org/deliver/etsi_es/203700_203799/203790/01.03.01_60/es_203790v010301p.pdf)
*
******************************************************************************/
module classes {
type component CT {
port PT pt;
}
type port PT message { inout integer; } with { extension "internal" }
/*****************************
class tests
*****************************/
// minimal classes
type class MinimalClass { }
type class @abstract MinimalAbstractClass { }
type class @final MinimalFinalClass { }
type class @trait MinimalTraitClass { }
// components
type class ClassCT runs on CT mtc CT system CT { }
// inheritance
type class BaseClass { }
type class @abstract AbstractBaseClass { }
type class @trait TraitBaseClass { }
type class @trait TraitBaseClass2 { }
type class SubClass0 extends object { }
type class SubClass1 extends BaseClass {
const integer m_const := 1;
}
type class SubClass2 extends BaseClass, TraitBaseClass {
const integer m_const := 0;
}
type class SubClass3 extends BaseClass, TraitBaseClass, TraitBaseClass2 {
var integer m_int;
}
// members, methods and constructors
type class MembersClass {
private var integer m_int_priv := 1;
var integer m_int_prot := 2;
public var integer m_int_pub := 3;
public function f_get1() return integer {
return m_int_priv;
}
public function f_times2(in integer times) return integer {
return times * m_int_prot;
}
create (integer p1, integer p2) {
m_int_priv := p1;
m_int_prot := p2;
}
}
type union MyUnion {
integer choice1,
charstring choice2
}
type class VariousMembers {
private timer m_timer;
private const octetstring m_var_octet := 'ABCD'O;
public var charstring m_var1 := "abc";
public template MyUnion t_union := { choice1 := 12 }
private type class NestedClass {
private function f_dummy(in integer x) return integer {
return 1;
}
}
}
type class @trait AbstractMembersClass {
function @abstract f();
function @abstract f2(in integer p_int);
function @abstract f3(in integer p_int) return charstring;
}
// `this` reference
type class ClassWithThis {
public var integer a;
const float b;
create (integer a, float b) {
this.a := a;
this.b := b;
}
}
// `super` reference
type class SuperBaseClass {
private const integer m_const := 1;
public function f_get_const() return integer {
return m_const;
}
}
type class SubClass4 extends SuperBaseClass {
private const integer m_const2 := 2;
public function f_get_const() return integer {
return m_const2;
}
public function f_get_all_consts_sum() return integer {
var integer sum := 0;
sum := sum + f_get_const();
sum := sum + super.f_get_const();
return sum;
}
}
testcase tc_basicSyntax() runs on CT {
// var MinimalClass v_minimalClass := MinimalClass.create;
}
control {
execute(tc_basicSyntax());
}
}
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