Git Product home page Git Product logo

Comments (11)

frondeus avatar frondeus commented on June 24, 2024 1

@luke-biel - It's seems that we missed panics scenario.

@gh0st42 - it should not be a breaking change, its more a oversight in that case, therefore a bug. Sorry for that.
Please see #50 for more context.

For now, you skip this check by enabling feature allow_result.

from test-case.

frondeus avatar frondeus commented on June 24, 2024 1

Allright, I think this one deserves its own issue. Let me create one and then we should continue figuring out the right approach for it :)

from test-case.

luke-biel avatar luke-biel commented on June 24, 2024 1

Ah! Good to know about the silent failures!

I initially tried your suggestion to resolve the issue but you run into:

30 | #[test_case("ISBN:1839485743" => Ok(()); "isbn10")]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `dyn StdError == dyn StdError`
   |
   = help: the trait `PartialEq` is not implemented for `dyn StdError`
   = note: required because of the requirements on the impl of `PartialEq` for `Box<dyn StdError>`

I just tested locally that

    #[test_case("abc" => matches Ok(_))]
    fn dyn_err(input: &str) -> Result<(), Box<dyn std::error::Error>> {
        Ok(())
    }

works. It may be a solution in your case untill we introduce proper handling of Result.

from test-case.

gh0st42 avatar gh0st42 commented on June 24, 2024 1

@gh0st42 - Is your case solved?

yes, version 1.2.3 works again even without the allow_result feature.
thank you for the quick response.

from test-case.

luke-biel avatar luke-biel commented on June 24, 2024

Mea culpa. I overlooked this. Fix is on it's way, just needs a review.

from test-case.

luke-biel avatar luke-biel commented on June 24, 2024

1.2.3 was just published

from test-case.

bspradling avatar bspradling commented on June 24, 2024

I'm still receiving the same error above on 1.2.3 with the following test:

#[test_case("ISBN:1839485743"; "isbn10")]
#[test_case("ISBN:1839485743123"; "isbn13")]
#[tokio::test]
async fn test_bibliography_key_serde(expected: &str) -> Result<(), Box<dyn Error>> {
    let key: BibliographyKey = serde_json::from_str(expected)?;
    let actual = serde_json::to_string(&key)?;
    assert_eq!(expected, actual);
    Ok(())
}

from test-case.

frondeus avatar frondeus commented on June 24, 2024

@bspradling In that case this is expected behavior.

Your tests were passing silently, so even if there was an Err() the test would pass.
For now, v1.2.2 introduced a compile-time error so you can review this test.

Currently test_case does not support implicit Result<(), Box<dyn Error>> handling which was introduced in Edition 2018.
To solve this problem you should use test case syntax to expect value explicitly.

In your case:

#[test_case("ISBN:1839485743" => Ok(()) ; "isbn10")]
#[test_case("ISBN:1839485743123" => Ok(()) ; "isbn13")]
#[tokio::test]
async fn test_bibliography_key_serde(expected: &str) -> Result<(), Box<dyn Error>> {
    let key: BibliographyKey = serde_json::from_str(expected)?;
    let actual = serde_json::to_string(&key)?;
    assert_eq!(expected, actual);
    Ok(())
}

This should work.

We know that in long term we need to allow implicit Result<(), dyn Err> but our priority was to first prevent any silently failing cases. I hope you understand it.

from test-case.

bspradling avatar bspradling commented on June 24, 2024

Ah! Good to know about the silent failures!

I initially tried your suggestion to resolve the issue but you run into:

30 | #[test_case("ISBN:1839485743" => Ok(()); "isbn10")]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `dyn StdError == dyn StdError`
   |
   = help: the trait `PartialEq` is not implemented for `dyn StdError`
   = note: required because of the requirements on the impl of `PartialEq` for `Box<dyn StdError>`

from test-case.

frondeus avatar frondeus commented on June 24, 2024

Actually it might be just a edge-case of #50

from test-case.

frondeus avatar frondeus commented on June 24, 2024

@gh0st42 - Is your case solved?

from test-case.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.