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

Skip to content

Commit 05adfa2

Browse files
committed
Moving expectations for compound into single type and removing expectation_cursors to allow anydata to inherit
1 parent 898bec2 commit 05adfa2

17 files changed

Lines changed: 139 additions & 186 deletions

source/api/ut.pkb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ create or replace package body ut is
2828
return ut_runner.version();
2929
end;
3030

31-
function expect(a_actual in anydata, a_message varchar2 := null) return ut_expectation_refcursor is
31+
function expect(a_actual in anydata, a_message varchar2 := null) return ut_expectation_compound is
3232
begin
33-
return ut_expectation_refcursor(ut_data_value_anydata(a_actual), a_message);
33+
return ut_expectation_compound(ut_data_value_anydata(a_actual), a_message);
3434
end;
3535

3636
function expect(a_actual in blob, a_message varchar2 := null) return ut_expectation is
@@ -78,9 +78,9 @@ create or replace package body ut is
7878
return ut_expectation(ut_data_value_varchar2(a_actual), a_message);
7979
end;
8080

81-
function expect(a_actual in sys_refcursor, a_message varchar2 := null) return ut_expectation_refcursor is
81+
function expect(a_actual in sys_refcursor, a_message varchar2 := null) return ut_expectation_compound is
8282
begin
83-
return ut_expectation_refcursor(ut_data_value_refcursor(a_actual), a_message);
83+
return ut_expectation_compound(ut_data_value_refcursor(a_actual), a_message);
8484
end;
8585

8686
function expect(a_actual in yminterval_unconstrained, a_message varchar2 := null) return ut_expectation is

source/api/ut.pks

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ create or replace package ut authid current_user as
1919

2020
function version return varchar2;
2121

22-
function expect(a_actual in anydata, a_message varchar2 := null) return ut_expectation_refcursor;
22+
function expect(a_actual in anydata, a_message varchar2 := null) return ut_expectation_compound;
2323

2424
function expect(a_actual in blob, a_message varchar2 := null) return ut_expectation;
2525

@@ -31,7 +31,7 @@ create or replace package ut authid current_user as
3131

3232
function expect(a_actual in number, a_message varchar2 := null) return ut_expectation;
3333

34-
function expect(a_actual in sys_refcursor, a_message varchar2 := null) return ut_expectation_refcursor;
34+
function expect(a_actual in sys_refcursor, a_message varchar2 := null) return ut_expectation_compound;
3535

3636
function expect(a_actual in timestamp_unconstrained, a_message varchar2 := null) return ut_expectation;
3737

source/create_synonyms_and_grants_for_public.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ alter session set current_schema = &&ut3_owner;
3333

3434
grant execute on &&ut3_owner..ut_expectation to public;
3535
grant execute on &&ut3_owner..ut_expectation_compound to public;
36-
grant execute on &&ut3_owner..ut_expectation_refcursor to public;
3736
grant execute on &&ut3_owner..ut_be_between to public;
3837
grant execute on &&ut3_owner..ut_be_empty to public;
3938
grant execute on &&ut3_owner..ut_be_false to public;
@@ -111,7 +110,6 @@ prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to PUBLIC
111110

112111
create public synonym ut_expectation for &&ut3_owner..ut_expectation;
113112
create public synonym ut_expectation_compound for &&ut3_owner..ut_expectation_compound;
114-
create public synonym ut_expectation_refcursor for &&ut3_owner..ut_expectation_refcursor;
115113

116114
create public synonym be_between for &&ut3_owner..be_between;
117115
create public synonym be_empty for &&ut3_owner..be_empty;

source/create_user_grants.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ alter session set current_schema = &&ut3_owner;
5353

5454
grant execute on &&ut3_owner..ut_expectation to &ut3_user;
5555
grant execute on &&ut3_owner..ut_expectation_compound to &ut3_user;
56-
grant execute on &&ut3_owner..ut_expectation_refcursor to &ut3_user;
5756

5857
grant execute on &&ut3_owner..ut_be_between to &ut3_user;
5958
grant execute on &&ut3_owner..ut_be_empty to &ut3_user;

source/create_user_synonyms.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to user &&ut3
5555

5656
create or replace synonym &ut3_user..ut_expectation for &&ut3_owner..ut_expectation;
5757
create or replace synonym &ut3_user..ut_expectation_compound for &&ut3_owner..ut_expectation_compound;
58-
create or replace synonym &ut3_user..ut_expectation_refcursor for &&ut3_owner..ut_expectation_refcursor;
5958

6059
create or replace synonym &ut3_user..be_between for &&ut3_owner..be_between;
6160
create or replace synonym &ut3_user..be_empty for &&ut3_owner..be_empty;

source/expectations/matchers/ut_contain.tpb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ create or replace type body ut_contain as
2323
return;
2424
end;
2525

26+
constructor function ut_contain(self in out nocopy ut_contain, a_expected anydata) return self as result is
27+
begin
28+
self.init(ut_data_value_anydata(a_expected), null, $$plsql_unit);
29+
self.options.unordered();
30+
return;
31+
end;
32+
2633
overriding member function run_matcher(self in out nocopy ut_contain, a_actual ut_data_value) return boolean is
2734
l_result boolean;
2835
begin

source/expectations/matchers/ut_contain.tps

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ create or replace type ut_contain under ut_equal(
2424
*/
2525

2626
constructor function ut_contain(self in out nocopy ut_contain, a_expected sys_refcursor) return self as result,
27+
constructor function ut_contain(self in out nocopy ut_contain, a_expected anydata) return self as result,
2728
overriding member function run_matcher(self in out nocopy ut_contain, a_actual ut_data_value) return boolean,
2829
overriding member function run_matcher_negated(self in out nocopy ut_contain, a_actual ut_data_value) return boolean,
2930
overriding member function failure_message(a_actual ut_data_value) return varchar2,
3031
overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2
3132
)
32-
/
33+

source/expectations/ut_expectation.tpb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,5 +691,15 @@ create or replace type body ut_expectation as
691691
self.not_to( ut_contain(a_expected).negated() );
692692
end;
693693

694+
member procedure to_contain(self in ut_expectation, a_expected anydata) is
695+
begin
696+
self.to_( ut_contain(a_expected) );
697+
end;
698+
699+
member procedure not_to_contain(self in ut_expectation, a_expected anydata) is
700+
begin
701+
self.not_to( ut_contain(a_expected).negated() );
702+
end;
703+
694704
end;
695705
/

source/expectations/ut_expectation.tps

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ create or replace type ut_expectation authid current_user as object(
161161
member procedure not_to_be_less_than(self in ut_expectation, a_expected yminterval_unconstrained),
162162

163163
member procedure to_contain(self in ut_expectation, a_expected sys_refcursor),
164-
member procedure not_to_contain(self in ut_expectation, a_expected sys_refcursor)
164+
member procedure not_to_contain(self in ut_expectation, a_expected sys_refcursor),
165+
member procedure to_contain(self in ut_expectation, a_expected anydata),
166+
member procedure not_to_contain(self in ut_expectation, a_expected anydata)
165167

166168
)
167169
not final

source/expectations/ut_expectation_compound.tpb

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,48 @@ create or replace type body ut_expectation_compound as
5858
return l_result;
5959
end;
6060

61+
member function to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_compound is
62+
l_result ut_expectation_compound := self;
63+
begin
64+
l_result.matcher := ut_equal(a_expected, a_nulls_are_equal);
65+
return l_result;
66+
end;
67+
68+
member function not_to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_compound is
69+
l_result ut_expectation_compound := self;
70+
begin
71+
l_result.matcher := ut_equal(a_expected, a_nulls_are_equal).negated();
72+
return l_result;
73+
end;
74+
75+
member function to_contain(a_expected sys_refcursor) return ut_expectation_compound is
76+
l_result ut_expectation_compound := self;
77+
begin
78+
l_result.matcher := ut_contain(a_expected);
79+
return l_result;
80+
end;
81+
82+
member function not_to_contain(a_expected sys_refcursor) return ut_expectation_compound is
83+
l_result ut_expectation_compound := self;
84+
begin
85+
l_result.matcher := ut_contain(a_expected).negated();
86+
return l_result;
87+
end;
88+
89+
member function to_contain(a_expected anydata) return ut_expectation_compound is
90+
l_result ut_expectation_compound := self;
91+
begin
92+
l_result.matcher := ut_contain(a_expected);
93+
return l_result;
94+
end;
95+
96+
member function not_to_contain(a_expected anydata) return ut_expectation_compound is
97+
l_result ut_expectation_compound := self;
98+
begin
99+
l_result.matcher := ut_contain(a_expected).negated();
100+
return l_result;
101+
end;
102+
61103
member function include(a_items varchar2) return ut_expectation_compound is
62104
begin
63105
return include( ut_varchar2_list( a_items ) );
@@ -137,5 +179,28 @@ create or replace type body ut_expectation_compound as
137179
self.to_( treat(matcher as ut_equal).join_by(a_columns) );
138180
end;
139181

182+
member function unordered_columns return ut_expectation_compound is
183+
l_result ut_expectation_compound;
184+
begin
185+
l_result := self;
186+
l_result.matcher := treat(l_result.matcher as ut_equal).unordered_columns;
187+
return l_result;
188+
end;
189+
190+
member procedure unordered_columns(self in ut_expectation_compound) is
191+
begin
192+
self.to_( treat(matcher as ut_equal).unordered_columns );
193+
end;
194+
195+
member function uc return ut_expectation_compound is
196+
begin
197+
return unordered_columns;
198+
end;
199+
200+
member procedure uc(self in ut_expectation_compound) is
201+
begin
202+
unordered_columns;
203+
end;
204+
140205
end;
141206
/

0 commit comments

Comments
 (0)