GithubHelp home page GithubHelp logo

string' test broken about megaparsec HOT 5 CLOSED

mrkkrp avatar mrkkrp commented on May 31, 2024
string' test broken

from megaparsec.

Comments (5)

mrkkrp avatar mrkkrp commented on May 31, 2024

Initially logic of string' was to return string cased as argument of the parser. This later was changed. It's strange that it took so many tests (iterations) to reveal this defect in the test. I'll investigate/fix it tomorrow when I have clearer state of mind. Enough hacking for today.

from megaparsec.

bkaestner avatar bkaestner commented on May 31, 2024

It's strange that it took so many tests to revel this defect in the test.

I've noticed that there are only property based tests, but not any with static values. This behavioural change could have been noticed with static tests. Maybe you want to add some in the future for edge cases? Not for every property, but it might be reasonable for string'. You could reuse the already written properties for them.

Either way, take your time. The culprit has been found, and it was "just" in a test, not in string' itself.

from megaparsec.

mrkkrp avatar mrkkrp commented on May 31, 2024

@bkaestner, another approach would be to modify existing test for string' so this sort of behavior would manifest itself with higher probability.

from megaparsec.

bkaestner avatar bkaestner commented on May 31, 2024

Hm. Something like this comes to mind:

-- Randomly change the case in the given string
fuzzyCase :: String -> Gen String
fuzzyCase s = do
    b <- vector (length s)
    return $ zipWith f s b
  where f k True  = if isLower k then toUpper k else toLower k
        f k False = k

prop_string'_fuzzied :: String -> Property
prop_string'_fuzzied a =
  forAll (fuzzyCase a) $ \s ->
   checkString' (string' a) a casei (showToken a) s

This would test string' with a string that only differs in case (and can be used together with the current test).

from megaparsec.

mrkkrp avatar mrkkrp commented on May 31, 2024

@bkaestner, I've fixed that bug (it was trivial Right a'Right s' in definition of checkString). I think I'll add your prop_string'_fuzzied to the test suite.

from megaparsec.

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.