Commit 762b9243 authored by balaskoa's avatar balaskoa
Browse files

typeCompat test added to Regression_Test_java


Signed-off-by: default avatarbalaskoa <Jeno.Balasko@ericsson.com>
parent 7b8d3053
--/////////////////////////////////////////////////////////////////////////////
-- Copyright (c) 2000-2019 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:
-- Balasko, Jeno
-- Kovacs, Ferenc
--
--/////////////////////////////////////////////////////////////////////////////
ASN-Ext
DEFINITIONS
AUTOMATIC TAGS
::=
BEGIN
IMPORTS;
Myrec1ASN ::= SEQUENCE {
f1 INTEGER OPTIONAL,
f2 INTEGER
}
Myrec2ASN ::= SEQUENCE {
f1 INTEGER,
f2 INTEGER
}
END
This diff is collapsed.
/******************************************************************************
* Copyright (c) 2000-2019 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:
* Balasko, Jeno
* Kovacs, Ferenc
*
******************************************************************************/
// Same as in "Compat.ttcn", but in a different module of the project. The
// tests from the "function_test" were moved here as well.
module Ext {
type component Empty { }
type integer I (0..2)
type float F
type anytype Atype
//** RECORDS **//
type record myrec1Ext {
integer f1 optional,
integer f2
}
type record myrec2Ext {
integer f1 optional,
integer f2
}
//** RECORDOFS **//
type record of integer myintlist1Ext
type record of integer myintlist2Ext
type record of myrec1Ext myr1listExt
type record of myrec2Ext myr2listExt
type record rtype { integer i1, integer i2 }
type record of integer r1type
template r1type t1 := { 1, 2 }
template rtype t modifies t1 := { 2, 1 }
testcase tc_ExtMatch() runs on Empty {
// Normal templates.
if (match({ 1, 2 }, t1)) { setverdict(pass) } else { setverdict(fail) }
if (match({ 2, 1 }, t)) { setverdict(pass) } else { setverdict(fail) }
// Same with local templates.
template r1type t1l := { 11, 22 }
template rtype tl modifies t1l := { 22, 11 }
if (match({ 11, 22 }, t1l)) { setverdict(pass) } else { setverdict(fail) }
if (match({ 22, 11 }, tl)) { setverdict(pass) } else { setverdict(fail) }
}
type record of recR recofR
type record recR { recofR rof optional }
type record c1 { recR f1 }
type record c11 { c1 f1 }
type record c2 { recofR f1 }
type record c22 { c2 f1 }
// Recursive type definitions.
testcase tc_Recursive() runs on Empty {
var recofR v_rof := { { omit } }
var recR v_r := { rof := omit }
var c11 cc1 := { f1 := { { omit } } }
var c22 cc2 := { f1 := { { { omit } } } }
//v_r := v_rof
if (v_r.rof == omit) { setverdict(pass) } else { setverdict(fail) }
//v_rof := v_r
}
testcase tc_ExtSimple() runs on Empty {
var myrec1Ext rec1 := { 1, 2 }
var myrec2Ext rec2 := { 1, 2 }
var myintlist1Ext il1 := { 1, 2 }
var myintlist2Ext il2 := { 9, 9 }
var myr1listExt r1l := { { 11, 22 }, { 33, 44 } }
var myr2listExt r2l := { { 0, 1 }, { 2, 3 } }
rec1 := rec2 ; rec2 := rec1
rec1 := il1 ; il1 := rec1
rec2 := il1 ; il1 := rec2
if (rec1 == rec2 and rec2 == rec1) { setverdict(pass) } else { setverdict(fail) }
if (rec1 != rec2 and rec2 != rec1) { setverdict(fail) } else { setverdict(pass) }
if (rec1 == il1 and il1 == rec1) { setverdict(pass) } else { setverdict(fail) }
if (rec1 != il1 and il1 != rec1) { setverdict(fail) } else { setverdict(pass) }
il1 := il2 ; il2 := il1
if (il1 == il2 and il2 == il1) { setverdict(pass) } else { setverdict(fail) }
if (il1 != il2 and il2 != il1) { setverdict(fail) } else { setverdict(pass) }
if (r1l == r2l or r2l == r1l) { setverdict(fail) } else { setverdict(pass) }
r1l := r2l
if (r1l == r2l or r2l == r1l) { setverdict(pass) } else { setverdict(fail) }
}
} with { extension "anytype I, F, integer, float" }
/******************************************************************************
* Copyright (c) 2000-2019 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:
* Balasko, Jeno
* Kovacs, Ferenc
*
******************************************************************************/
module Ext2 {
import from Ext all;
type integer I (0..2)
type anytype Atype
// In the standard all basic types are included by default.
} with { extension "anytype I, integer, float" }
/******************************************************************************
* Copyright (c) 2000-2019 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:
* Balasko, Jeno
* Kovacs, Ferenc
*
******************************************************************************/
// Examples from the standard.
module Std {
import from Ext all
import from Ext2 all
type component Empty { }
//** ENUMS **//
type enumerated MyEnum1 { E1, E2 }
type MyEnum1 MyEnum2
// 6.3.2.1 enumerated types are only compatible with their synonym types. It
// worked already in TITAN. It's just a "typedef".
testcase tc_Enums() runs on Empty {
var MyEnum1 enum1 := E1
var MyEnum2 enum2 := E2
if (enum1 == enum2 and enum2 == enum1) { setverdict(fail) } else { setverdict(pass) }
if (enum1 != enum2 and enum2 != enum1) { setverdict(pass) } else { setverdict(fail) }
enum1 := enum2
enum2 := enum1
if (enum1 == enum2 and enum2 == enum1) { setverdict(pass) } else { setverdict(fail) }
if (enum1 != enum2 and enum2 != enum1) { setverdict(fail) } else { setverdict(pass) }
}
//** RECORDS **//
type record AType {
integer a(0..10) optional,
integer b(0..10) optional,
boolean c
}
type record BType {
integer a optional,
integer b(0..10) optional,
boolean c
}
// Field names doesn't matter.
type record CType {
integer d optional,
integer e optional,
boolean f
}
type record DType {
integer a optional,
integer b optional,
boolean c optional
}
type record EType {
integer a optional,
integer b optional,
boolean c,
float d optional
}
type record HType {
integer a,
integer b optional,
integer c
}
type record JType {
HType H,
integer b optional,
integer c
}
// 6.3.2.2 the # of fields and the optionality must be the same. Restrictions
// on basic-type fields are not checked at run-time.
testcase tc_Records() runs on Empty {
var AType MyVarA := { -, 1, true }
var BType MyVarB := { omit, 2, true }
var CType MyVarC := { 3, omit, true }
var DType MyVarD := { 4, 4, true }
var EType MyVarE := { 5, 5, true, omit }
MyVarA := MyVarB
MyVarC := MyVarB
if (MyVarA == { omit, 2, true }) { setverdict(pass) } else { setverdict(fail) }
if (MyVarC == { omit, 2, true }) { setverdict(pass) } else { setverdict(fail) }
// "MyVarA := MyVarD" (Compile-time error, optionality doesn't match.)
// "MyVarA := MyVarE" (Compile-time error, # of fields doesn't match.)
MyVarC := { d := 20 }
MyVarA := MyVarC // TITAN won't check it at run-time.
}
//** RECORDOFS **//
type record of integer IType
// 6.3.2.2 missing optional fields of records won't be assigned to record ofs
// or arrays. Checking for OMIT_VALUE seems to be good for templates as well.
// Omit fields will stay unbound in list types. Since adding an omitted record
// field into the initialization list of a list type causes error, it seems to
// be the right thing to do.
testcase tc_RecordOfsArrays() runs on Empty {
var HType MyVarH := { 1, omit, 3 }
var IType MyVarI
var integer MyArrayVar[2]
MyArrayVar := MyVarH
MyVarH := { -, 2, - } // Avoid unbound error.
MyVarI := MyVarH
MyVarI[__LINE__] := __LINE__
if (not isvalue(MyVarI) and MyVarI[0] == MyVarI[1] - 1) { setverdict(pass) } else { setverdict(fail) }
if (isvalue(MyVarI) and not MyVarI[0] == MyVarI[1] - 1) { setverdict(fail) } else { setverdict(pass) }
MyVarI := { 3, 4 }
// "MyVarH := MyVarI" is a run-time error. The record of doesn't have enough elements.
}
//** SETS **//
type set FType {
integer a optional,
integer b optional,
boolean c
}
type set GType {
integer d optional,
integer e optional,
boolean f
}
// Examples from section 6.3.2.3.
testcase tc_SetsSetOfs() runs on Empty {
var FType MyVarF := { a := 1, c := true }
var GType MyVarG := { f := true, d := 7 }
var AType MyVarA := { -, 1, true }
// "MyVarF := MyVarG" is a bug in the standard. The unbound optional field
// will cause run-time error. We don't replace optional fields with
// OMIT_VALUE in this case.
if (not isvalue(MyVarF) and MyVarF.a == 1 and MyVarF.c == true) { setverdict(pass) } else { setverdict(fail) }
if (isvalue(MyVarF) and not MyVarF.a == 1 and MyVarF.c == true) { setverdict(fail) } else { setverdict(pass) }
MyVarG.e := omit // Complete the example.
MyVarF := MyVarG
if (MyVarF == MyVarG and MyVarG == MyVarF) { setverdict(pass) } else { setverdict(fail) }
if (MyVarF != MyVarG and MyVarG != MyVarF) { setverdict(fail) } else { setverdict(pass) }
// "MyVarF := MyVarA" is a compile-time error.
}
//** UNIONS **//
type union U1 { integer i }
type union U2 { integer i, boolean b }
type union U {
integer I (0..2)
}
testcase tc_Unions() runs on Empty {
var U1 u1 := { i := 1 }
var U2 u2 := u1
u1 := u2
u1 := u2
if (u1 == u2 and u2 == u1) { setverdict(pass) } else { setverdict(fail) }
if (u1 != u2 and u2 != u1) { setverdict(fail) } else { setverdict(pass) }
if (ischosen(u1.i)) { setverdict(pass) } else { setverdict(fail) }
if (ischosen(u2.i)) { setverdict(pass) } else { setverdict(fail) }
u2 := { b := true }
// "u1 := u2" is a run-time error. No compatible alternative with the same name.
// "var anytype x := u1" is a compile-time error.
}
testcase tc_Anytypes() runs on Empty {
var Ext.Atype Exta
var Ext.Atype ExtaI := { I := 1 }
var Ext.Atype ExtaF := { F := 1.0 }
// In 6.3.2.5 "integer" was not added, only "I". So, I added it manually.
// By default all basic types are included in anytype, but not for us.
var Ext2.Atype Ext2a := { integer := 1 }
var Ext2.Atype Ext2aI := { I := 1 }
var U u := { I := 1 }
Exta := Ext2a
if (Exta == Ext2a and Ext2a == Exta) { setverdict(pass) } else { setverdict(fail) }
if (Exta != Ext2a and Ext2a != Exta) { setverdict(fail) } else { setverdict(pass) }
if (Exta.integer == Ext2a.integer) { setverdict(pass) } else { setverdict(fail) }
// "Exta := u" is a compile-time error.
// "Exta := Ext2aI" is a run-time error, since the name of the module counts.
Ext2a := { float := 1.0 }
// "Exta := Ext2aI" same run-time error as above.
// "Ext2a := ExtaF" ditto.
}
testcase tc_Substruct() runs on Empty {
var JType MyVarJ
var HType MyVarH := { 1, omit, 3 }
var IType MyVarI
MyVarJ.H := MyVarH
// HL51459 related changes.
MyVarJ.H := { -, 2, - }
MyVarI := MyVarJ.H
MyVarH := MyVarI
if (MyVarJ.H == MyVarH and MyVarH == MyVarJ.H) { setverdict(pass) } else { setverdict(fail) }
if (MyVarJ.H != MyVarH and MyVarH != MyVarJ.H) { setverdict(fail) } else { setverdict(pass) }
// "MyVarI == MyVarJ.H" would be a run-time error, since the right operand
// has an unbound field.
if ({ 1, 2, 3 } == MyVarJ.H) { setverdict(pass) } else { setverdict(fail) }
}
}
###############################################################################
# Copyright (c) 2000-2019 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:
# Balasko, Jeno
# Kovacs, Ferenc
#
###############################################################################
[MODULE_PARAMETERS]
[LOGGING]
Logfile := "Compat.log"
FileMask := LOG_ALL
ConsoleMask := TTCN_WARNING | TTCN_ERROR | TTCN_TESTCASE | TTCN_STATISTICS | TTCN_USER
[EXECUTE]
Compat.control
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