GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — not_to(contain) fails while not_to_contain passes · Issue #1245 · utPLSQL/utPLSQL

not_to(contain) fails while not_to_contain passes #1245

New issue
Copy link
New issue
Copy link
Closed
#1246
Closed
not_to(contain) fails while not_to_contain passes#1245
#1246
Copy link
Assignees
lwasylow
Labels
bug
Milestone
v3.1.14

Description

@micdol
micdol
opened on Feb 28, 2023
Issue body actions

Describe the bug
Logically not_to(contain) should be the same as not_to_contain however the former fails while the latter passes. See reproduction steps for code.

Provide version info
utPLSQL: v3.1.14.4072-develop
Database: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.18.0.0.0

Information about client software
SQLDeveloper, SQLPlus cmd line

To Reproduce

create or replace package example as
    --%suite(example)

    --%test
    procedure not_to_contain_passes;

    --%test
    procedure not_to_bracket_contain_bracket_fails;
end;
/

create or replace package body example as
    procedure not_to_contain_passes
        is
        c1 sys_refcursor;
        c2 sys_refcursor;
    begin
        open c1 for select 'a' as letter from dual union all select 'b' from dual;
        open c2 for select 'c' as letter from dual;
        ut.expect(c1).not_to_contain(c2); -- !!!
    end not_to_contain_passes;

    procedure not_to_bracket_contain_bracket_fails
        is
        c1 sys_refcursor;
        c2 sys_refcursor;
    begin
        open c1 for select 'a' as letter from dual union all select 'b' from dual;
        open c2 for select 'c' as letter from dual;
        ut.expect(c1).not_to(contain(c2)); -- !!!!
    end not_to_bracket_contain_bracket_fails;
end;
/

set serveroutput on;
execute ut.run(a_path => 'example');

Output:

example
  not_to_contain_passes [,011 sec]
  not_to_bracket_contain_bracket_fails [,014 sec] (FAILED - 1)
 
Failures:
 
  1) not_to_bracket_contain_bracket_fails
      Actual: (refcursor [ count = 2 ])
          Data-types:
          <LETTER>CHAR</LETTER>
          Data:
          <ROW><LETTER>a</LETTER></ROW><ROW><LETTER>b</LETTER></ROW>
       was expected not to contain:(refcursor [ count = 1 ])
          Data-types:
          <LETTER>CHAR</LETTER>
          Data:
          <ROW><LETTER>c</LETTER></ROW>
      at "RDP_MYCO_APEX_UT.EXAMPLE.NOT_TO_BRACKET_CONTAIN_BRACKET_FAILS", line 19 ut.expect(c1).not_to(contain(c2)); -- !!!!
       
Finished in ,026737 seconds
2 tests, 1 failed, 0 errored, 0 disabled, 0 warning(s)

Expected behavior
not_to_contain should work the same way as not_to(contain)

Activity

  1. lwasylow commented on Mar 1, 2023

    @lwasylow
    lwasylow
    on Mar 1, 2023
    Member
    More actions

    It's arguable:) not is here negation.
    So you asking if the set contains the other set and then negating result.
    I that case results of to contain coming as false and then you apply not to negate which result in true.

    So in fact what you asking is negate result of check to_contain which is not the same as not_contain.

    This is my suspicion would need to look into code to confirm.
    I'm pretty sure we had that discussion with team or another ticket and operator not is used to negation of result.
    With sets is getting a bit more blurry but given that you have there a proper operator to use don't think is a showstopper.

    Let me know if that's answer your question.

  2. micdol commented on Mar 1, 2023

    @micdol
    micdol
    on Mar 1, 2023
    Author
    More actions

    To be honest I' struggling to understand the reasoning here. In comparisonnot_to_equal/not_to(equal) works as I'd expect. Can you give an example of actual case where this difference could be used please?


    By the way, I found the following entry in the documentation

    The negated version of contain ( not_to_contain ) is successful only when all values from expected set are not part of actual (they are disjoint and there is no overlap).

    So this might suggest a difference you mentioned... And looking into source of ut_expectations.tpb line 687:

      member procedure not_to_contain(self in ut_expectation, a_expected sys_refcursor) is
      begin
        self.not_to( ut_contain(a_expected).negated() );
      end;

    I think this is what you mentioned, yet again I do not understand why. This double negation not_to + .negated() seems off - compare this matcher to all the other not_to_XXX matchers in the file.

  3. lwasylow commented on Mar 1, 2023

    @lwasylow
    lwasylow
    on Mar 1, 2023
    Member
    More actions

    The negated is a member function that set a flag on matcher to set it to negated. So it does not provide a double negation logic from what I see.

    There is an extra logic when that flag is set which is probably the reason why you getting wrong results using not_to() without that flag.

    It feels counterintuitive the way it working at the moment for this, you are correct.
    I will look closer into this when got a moment.
    For time being please use not_to_contain version which I think working as expected.

  4. lwasylow
    added
    bug
    on Mar 1, 2023
  5. jgebal commented on Mar 2, 2023

    @jgebal
    jgebal
    on Mar 2, 2023
    Member
    More actions

    I agree that not_to_contain() should act exactly the same as not_to( contain() )
    It's a bug and needs yo be fixed.

    Nice catch @micdol and thanks for reporting it.

    Side question.
    Do you actually use the not_to( contain() ) syntax and if so why this over the other one.
    Are you using some sotr of dynamic testing?

    Om really curious of your use case.

  6. micdol commented on Mar 2, 2023

    @micdol
    micdol
    on Mar 2, 2023
    Author
    More actions

    I use not_to(contain) cause my primary code editor, IntelliJ, recognizes and applies syntax highlighting for it, while it fails to do so for not_to_contain.

  7. kukimik commented on Mar 13, 2023

    @kukimik
    kukimik
    on Mar 13, 2023
    Contributor
    More actions

    See #1173 (comment)

  8. lwasylow
    self-assigned this
    on Mar 15, 2023
  9. jgebal
    closed this as completedin #1246on Mar 19, 2023
  10. jgebal
    added this to the v3.1.14 milestone on May 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @lwasylow
    lwasylow

Labels

bug

Type

No type

Projects

No projects

    Milestone

    • v3.1.14

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.