Repository navigation
add property tests for fast division routines - #46
Conversation
| Data.ByteString.UTF8.Normalize | ||
| Data.Text.Normalize | ||
| Data.Unicode.Types | ||
| Data.Unicode.Internal.Division |
There was a problem hiding this comment.
I'm reluctant to expose this module. Could we possibly use an internal library for it?
There was a problem hiding this comment.
Earlier I was of the view to not expose Internal modules. But I have stopped caring about it now. It just became a hassle, and we also had some trouble with internal libraries. So in streamly now we have just exposed everything. If you care about it, you can give a try to the internal library.
| putStrLn "quotRem28" | ||
| check $ \n -> n `quotRem` 28 == quotRem28 n | ||
| putStrLn "quotRem21" | ||
| check $ \n -> n `quotRem` 21 == quotRem21 n |
There was a problem hiding this comment.
- Strictly speaking,
quotRem21andquotRem28are valid only for non-negative inputs, I'm a bit surprised that they pass as is. - It is important to check the upper end of range as well, like
check $ \n -> quotRem (maxBound - n) 21 == quotRem 21 (maxBound - n).
There was a problem hiding this comment.
The tests were indeed failing, but the result was showing as passed, I fixed that.
The division works correctly upto maxBound / 2, fails beyond that.
| (fromIntegral n) `quotRem` 21 == quotRem21 (fromIntegral n) | ||
| prop "quotRem21 maxBound" $ \(n :: Word) -> | ||
| let n1 = maxBound `div` 2 - n | ||
| in (fromIntegral n1) `quotRem` 21 == quotRem21 (fromIntegral n1) |
There was a problem hiding this comment.
I think it could look simpler with NonNegative wrapper:
import Test.QuickCheck (NonNegative(..))
...
prop "quotRem28" $ \(NonNegative n) -> n `quotRem` 28 == quotRem28 n
prop "quotRem28 maxBound" $ \(NonNegative n') ->
let n = maxBound - n' in n `quotRem` 28 == quotRem28 n
prop "quotRem21" $ \(NonNegative n) -> n `quotRem` 21 == quotRem21 n
prop "quotRem21 maxBound" $ \(NonNegative n') ->
let n = maxBound - n' in n `quotRem` 21 == quotRem21 n7e0953f to
a75dffa
Compare
|
@Bodigrim I made the fixes as suggested by you. I also made an internal library for testing instead of exposing the internal module. Let me know if this looks good. |
|
The coverage build is not working due to internal library. This may be one of the reasons why we did not use internal libraries earlier: |
|
I tried a hack to symlink only the internal module that we are trying to test for using in the tests. I could not find a better way to do this without exposing the module. I tried pulling the module into the test executable right from its current location without symlinking it into a separate directory but that does not work because cabal then starts picking up all the modules in the Let me know if there is a better way to do this which does not require disabling coverage. |
|
Ah, symlinks do not work on Windows. So there seems to be no way. |
|
Maybe add |
|
Ok, I have exposed the module and hidden the haddock. |
|
Any ideas what's wrong with ICU tests? |
|
The test passes on my machine which has The travis test is using libicu55 from Ubuntu xenial. We can try if libicu55 reproduces this error then we can perhaps say its because of old icu lib. If we cannot reproduce with that then something weird is going on. |
|
We can also try using Ubuntu bionic in the CI tests, we will have to find a way to install icu on bionic. |
|
It seems codepoint |
|
I see. As long as we know that it is an obsolete ICU who is wrong and not |
|
We need minimum icu-64 to avoid this issue. I will check where to get it from and how to install it on travis. This also raises another important question: should we bump the major version of unicode-transforms whenever we add support for a new version of Unicode? Though unicode is upward compatible so I guess there should not be any issues, but I am not very sure as I am not an expert. |
|
ICU official page redirects to its github release page: https://github.com/unicode-org/icu/releases/tag/release-67-1 where I can find a ubuntu focal seems to have icu66 we can try that: https://packages.ubuntu.com/focal/libicu66 |
|
I found a Lauchpad PPA, which claims to provide icu-66 for ubuntu bionic: https://launchpad.net/~pkgcrosswire/+archive/ubuntu/ppa/+packages |
|
LGTM! |
f6f8039 to
4bd7e8b
Compare
No description provided.