ETSI's Bug Tracker - Part 01: TTCN-3 Core Language
View Issue Details

ID | Project | Category | View Status | Date Submitted | Last Update
0005769 | Part 01: TTCN-3 Core Language | Technical | public | 28-09-2010 15:23 | 11-07-2012 09:56

Reporter | Jacob Wieland - Spirent |
Assigned To | Ina Schieferdecker |
Priority | normal | Severity | minor | Reproducibility | always
Status | closed | Resolution | fixed |
Platform |  | OS |  | OS Version |
Product Version |  |
Target Version | v4.5.1 (published 2013-04) | Fixed in Version | v4.5.1 (published 2013-04) |
Clause Reference(s) | C.33
Source (company - Author) | Testing Technologies - Jacob Wieland

Summary | 0005769: regexp introduces expression inconsistency

Description

In the description of regexp, the examples use expressions for the 'expression' paramter like:
charstring:"?(text)?"
In all other contexts in TTCN-3, this has the meaning: matching the value "?(text)?" as opposed to charstring:pattern "?(text)?" which has the meaning matching all values which have length 8 and have the substring '(text)' in the middle.
Former versions of the standard allowed expressions like regexp(v, "?(text)?", x) as a shorthand for regexp(v, charstring:pattern "?(text)?", x). Even though this already is inconsistent with the rest of the language, where string literals stand for their values and not for a pattern unless prepended by 'pattern', it is an understandable shorthand and since the expression cannot be referenced, it's meaning is properly defined by its place of usage. But now, allowing the expression charstring:"?(text)?", as well, suggests to the user that if he had a VALUE variable p of type charstring which contains "?(text)?" as its current value and then wrote regexp(v, charstring:p, x) this means the same as regexp(v, charstring:"?(text)?", x).
This again would mean that the tool would never be able to process such expressions statically, but only at runtime and since such expressions can contain references to other variables, this would mean that all context information about such variables would have to be available at runtime as well (per some sort of 'reflection') to enable the tool to produce the proper matching algorithm. Since reflection at runtime is always costly, such a consequence is undesirable and should be avoided.
Therefore, the describing text and the examples should be changed in such a way that if expression p is:
- a string literal it is a shorthand for 'pattern p'
- this would mean that this pattern is automatically assumed to be of the
same base string type as inpar
- an inline template it is interpreted like inline templates in the language everywhere else,
i.e. charstring:"?(text)?" is not the same as charstring:pattern "?(text)?"
- a value reference of basetype c it is taken literally, i.e. it is treated like c:p, meaning all characters that have special meaning in patterns are treated in the regular expressions as if they were escaped by a '\', thus matching only the value p.
- a template reference of basetype c, then this will be treated like a value or pattern if it is a value or pattern template, otherwise, it will cause an error.
As a compromise (even though it would leave the inconsistency intact), inline templates with an explicit string literal could still be allowed with the same meaning as is described now in the text, however, this could be confusing for the user as then
var template charstring p := "?(text)?"
...
regexp(inpar, p, x)
would have a different meaning than
regexp(inpar, charstring:"?(text)?", x)

Steps To Reproduce |
Additional Information |
Tags | No tags attached.
Relationships |

Attached Files

PatternTest.zip (1,761) 24-05-2011 19:07
http://oldforge.etsi.org/mantis/file_download.php?file_id=2476&type=bug
CR5769-proposal.doc (90,624) 30-09-2011 16:16
http://oldforge.etsi.org/mantis/file_download.php?file_id=2588&type=bug
CR5769-proposal_v2.doc (96,768) 01-12-2011 16:05
http://oldforge.etsi.org/mantis/file_download.php?file_id=2648&type=bug
CR5769-proposal_v3.doc (100,352) 01-12-2011 17:41
http://oldforge.etsi.org/mantis/file_download.php?file_id=2652&type=bug
CR5769-proposal_v4.doc (100,352) 02-12-2011 09:20
http://oldforge.etsi.org/mantis/file_download.php?file_id=2653&type=bug

Issue History
Date Modified | Username | Field | Change
28-09-2010 15:23 | Jacob Wieland - Spirent | New Issue |
28-09-2010 15:23 | Jacob Wieland - Spirent | Clause Reference(s) | => C.33
28-09-2010 15:23 | Jacob Wieland - Spirent | Source (company - Author) | => Testing Technologies - Jacob Wieland
30-11-2010 09:44 | Ina Schieferdecker | Project | TTCN-3 Change Requests => Part 01: TTCN-3 Core Language
30-11-2010 11:33 | Jacob Wieland - Spirent | Description Updated |
13-12-2010 12:43 | Gyorgy Rethy | Target Version | => Edition 4.3.2 (interim)
24-05-2011 16:58 | Gyorgy Rethy | Note Added: 0010035 |
24-05-2011 16:58 | Gyorgy Rethy | Status | new => assigned
24-05-2011 16:58 | Gyorgy Rethy | Assigned To | => Jacob Wieland - Spirent
24-05-2011 19:07 | Jacob Wieland - Spirent | File Added: PatternTest.zip |
24-05-2011 19:11 | Jacob Wieland - Spirent | Note Added: 0010040 |
27-09-2011 14:05 | Gyorgy Rethy | Target Version | Edition 4.3.2 (interim) => Edition 4.4.1
30-09-2011 16:10 | Jacob Wieland - Spirent | File Added: CR5769-proposal.doc |
30-09-2011 16:13 | Jacob Wieland - Spirent | Note Added: 0010317 |
30-09-2011 16:16 | Jacob Wieland - Spirent | File Deleted: CR5769-proposal.doc |
30-09-2011 16:16 | Jacob Wieland - Spirent | File Added: CR5769-proposal.doc |
29-11-2011 12:33 | Jacob Wieland - Spirent | Assigned To | Jacob Wieland - Spirent => Gyorgy Rethy
29-11-2011 12:33 | Jacob Wieland - Spirent | Note Added: 0010389 |
01-12-2011 16:05 | Gyorgy Rethy | File Added: CR5769-proposal_v2.doc |
01-12-2011 16:07 | Gyorgy Rethy | Note Added: 0010490 |
01-12-2011 16:07 | Gyorgy Rethy | Note Edited: 0010490 |
01-12-2011 16:08 | Gyorgy Rethy | Note Edited: 0010490 |
01-12-2011 16:08 | Gyorgy Rethy | Assigned To | Gyorgy Rethy => Ina Schieferdecker
01-12-2011 16:27 | Jacob Wieland - Spirent | Note Added: 0010493 |
01-12-2011 17:19 | Gyorgy Rethy | File Added: regexp.zip |
01-12-2011 17:27 | Gyorgy Rethy | File Deleted: regexp.zip |
01-12-2011 17:40 | Gyorgy Rethy | Note Added: 0010495 |
01-12-2011 17:41 | Gyorgy Rethy | File Added: CR5769-proposal_v3.doc |
01-12-2011 17:42 | Gyorgy Rethy | Note Edited: 0010495 |
01-12-2011 17:42 | Gyorgy Rethy | Assigned To | Ina Schieferdecker => Jacob Wieland - Spirent
01-12-2011 17:43 | Gyorgy Rethy | Note Edited: 0010495 |
02-12-2011 09:12 | Gyorgy Rethy | Note Added: 0010499 |
02-12-2011 09:20 | Gyorgy Rethy | File Added: CR5769-proposal_v4.doc |
02-12-2011 10:38 | Jacob Wieland - Spirent | Note Added: 0010504 |
02-12-2011 10:41 | Jacob Wieland - Spirent | Status | assigned => resolved
02-12-2011 10:41 | Jacob Wieland - Spirent | Resolution | open => fixed
02-12-2011 10:41 | Jacob Wieland - Spirent | Note Added: 0010505 |
02-12-2011 13:43 | Gyorgy Rethy | Assigned To | Jacob Wieland - Spirent => Ina Schieferdecker
02-12-2011 13:43 | Gyorgy Rethy | Status | resolved => feedback
02-12-2011 13:43 | Gyorgy Rethy | Resolution | fixed => reopened
02-12-2011 13:43 | Gyorgy Rethy | Note Added: 0010520 |
02-12-2011 13:43 | Gyorgy Rethy | Status | feedback => resolved
02-12-2011 13:43 | Gyorgy Rethy | Resolution | reopened => fixed
02-12-2011 13:43 | Gyorgy Rethy | Fixed in Version | => Edition 4.4.1
09-07-2012 17:15 | Ina Schieferdecker | Fixed in Version | Edition 4.4.1 =>
09-07-2012 17:15 | Ina Schieferdecker | Target Version | Edition 4.4.1 => Edition 4.5.1
11-07-2012 09:56 | Ina Schieferdecker | Note Added: 0010801 |
11-07-2012 09:56 | Ina Schieferdecker | Status | resolved => closed
11-07-2012 09:56 | Ina Schieferdecker | Fixed in Version | => Edition 4.5.1

Notes

(0010035)
Gyorgy Rethy
24-05-2011 16:58

Check with tool vendors what is implemented: reference of local constants, local variables, global constants, module parameters etc. Write a test code and ask vendors to return the result.

(0010040)
Jacob Wieland - Spirent
24-05-2011 19:11

If the implementation is standard-conform, the testcases in PatternTest.zip should either pass or give the error verdict (respective to their description).

(0010317)
Jacob Wieland - Spirent
30-09-2011 16:13

Discussion with Gyorgy yielded the following compromise. A note is added that local definitions cannot be referenced from a regular expression which is interpreted from a value-template, as the regexp function has no access to local definitions. Trying to reference unknown references will lead to a test case error.
I also added another note saying that the regular expression needs to be well-formed to not result in a test case error.

(0010389)
Jacob Wieland - Spirent
29-11-2011 12:33

please review

(0010490)
Gyorgy Rethy
01-12-2011 16:07 (edited on: 01-12-2011 16:08)

CR5769-proposal_v2.doc: as discussed with Jacob, the requirement that global definition names shall be qualified is deleted and some editorials. pls. make a final review, from my side is OK.

(0010493)
Jacob Wieland - Spirent
01-12-2011 16:27

If unqualified references shall be resolvable at runtime, the following testcase should pass.
module A {
const charstring x := "foo";
const charstring y := "bar";
}
module B {
import from A all;
function f(charstring pat) {
const charstring result := regexp("foobar", pat, 0);
if (result == "foo" or result == "bar") {
setverdict (pass);
}
}
type component C {}
testcase T() runs on C system C {
var boolean b := rnd() * 2.0 > 1.0;
if (b) {
f("*{x}*");
}
else {
f("*{y}*");
}
}
}

(0010495)
Gyorgy Rethy
01-12-2011 17:40 (edited on: 01-12-2011 17:43)

I understand your example, it will not work with values, only if the actual parameter of f() is a pattern. But these are two requirements that shall not be in notes, thus I made them body text. I have updated the proposed solution (CR5769-proposal_v3.doc), pls. review.

(0010499)
Gyorgy Rethy
02-12-2011 09:12

I have further simplified and clarified the text in CR5769-proposal_v4.doc. Pls. review this version instead of the previous versions.

(0010504)
Jacob Wieland - Spirent
02-12-2011 10:38

okay with me.

(0010505)
Jacob Wieland - Spirent
02-12-2011 10:41

problem resolved

(0010520)
Gyorgy Rethy
02-12-2011 13:43

Reopening the CR just to assign it Ina.

(0010801)
Ina Schieferdecker
11-07-2012 09:56

Implemented as proposed in v4