Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eb3b540

Browse files
committed
changed substr to regexp in ut_assert_processor.pkb
set who_called_expectation call only on failure
1 parent bf3bf1c commit eb3b540

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

source/core/types/ut_assert_result.tpb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ create or replace type body ut_assert_result is
2525
self.actual_type := a_actual_type;
2626
self.expected_value_string := a_expected_value_string;
2727
self.actual_value_string := a_actual_value_string;
28-
self.caller_info := ut_assert_processor.who_called_expectation();
28+
if a_result = ut_utils.tr_failure then
29+
self.caller_info := ut_assert_processor.who_called_expectation();
30+
end if;
2931
return;
3032
end ut_assert_result;
3133

source/core/ut_assert_processor.pkb

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,20 @@ create or replace package body ut_assert_processor as
112112
end;
113113

114114
function who_called_expectation return varchar2 is
115-
l_call_stack varchar2(32767) := dbms_utility.format_call_stack();
115+
c_call_stack constant varchar2(32767) := dbms_utility.format_call_stack();
116116
l_caller_stack_line varchar2(4000);
117117
l_caller_type_and_name varchar2(4000);
118118
l_line_no integer;
119-
l_owner varchar2(100);
120-
l_object_name varchar2(100);
121-
l_last_space_pos integer;
122-
l_object_delimiter_pos integer;
119+
l_owner varchar2(1000);
120+
l_object_name varchar2(1000);
123121
c_expectation_search_pattern constant varchar2(50) := '(.*\.UT_EXPECTATION[A-Z0-9#_$]*\s)+(.*)\s';
124122
begin
125-
l_caller_stack_line := regexp_substr( l_call_stack, c_expectation_search_pattern, 1, 1, 'm', 2);
126-
l_line_no := to_number( trim( substr( l_caller_stack_line, 11, 10 ) ) );
123+
l_caller_stack_line := regexp_substr( c_call_stack, c_expectation_search_pattern, 1, 1, 'm', 2);
124+
l_line_no := to_number( regexp_substr(l_caller_stack_line,'^\dx[0-9a-f]+\s+(\d+)',subexpression => 1) );
127125
l_caller_type_and_name := substr( l_caller_stack_line, 23 );
128-
l_last_space_pos := instr( l_caller_type_and_name, ' ', -1 );
129-
l_object_delimiter_pos := instr( l_caller_type_and_name, '.' );
130-
if l_object_delimiter_pos > 0 then
131-
l_owner := substr( l_caller_type_and_name, l_last_space_pos + 1, l_object_delimiter_pos - l_last_space_pos - 1 );
132-
l_object_name := substr( l_caller_type_and_name, l_object_delimiter_pos + 1 );
126+
if l_caller_stack_line like '%.%' then
127+
l_owner := regexp_substr(l_caller_stack_line,'\s(\w+)\.(\w|\.)+$',subexpression => 1);
128+
l_object_name := regexp_substr(l_caller_stack_line,'\s(\w+)\.((\w|\.)+)$',subexpression => 2);
133129
end if;
134130
return
135131
case when l_owner is not null and l_object_name is not null and l_line_no is not null then

0 commit comments

Comments
 (0)