Comments (5)
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.
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.
@bkaestner, another approach would be to modify existing test for string'
so this sort of behavior would manifest itself with higher probability.
from megaparsec.
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.
@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)
- [proposed labels: question, feature request] best practices for stateful matching of simple patterns HOT 4
- Question: mergeError HOT 2
- Greedy combinators HOT 11
- Problematic `IsString` instance HOT 4
- Processing input prior to parsing while retaining source positions HOT 1
- Mention in documentation that `parse` is an alias for `runParser` HOT 1
- MonadAccum instance for ParsecT HOT 5
- Tabs are not handled correctly when errors are rendered HOT 4
- Indentation error lost in alternative HOT 3
- `local` clears all hints HOT 5
- 9.4 migration: getSourcePos now requires `Monad m =>` HOT 6
- Remove/upgrade version bounds of executable `test-debug` from megaparsec-tests HOT 2
- Add `drop` to `Text.Megaparsec` HOT 3
- Wrong source locations on `unexpected end of input` with custom tokens HOT 2
- get col, row (as Int's) and error message of the first TrivialError HOT 2
- deepseq-1.5? HOT 1
- Error context with additional source positions HOT 4
- Parsing hexadecimal floats HOT 1
- Rewrite rules for parser primitives HOT 1
- How to use `Operator` from tutorial HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from megaparsec.