From 6b97d093b61b0b13854c83cbbb53fea62648d02e Mon Sep 17 00:00:00 2001 From: Robyn Speer Date: Thu, 18 Feb 2021 15:09:31 -0500 Subject: [PATCH] specifically test that the long sequence underflows to 0 --- tests/test_chinese.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_chinese.py b/tests/test_chinese.py index 83e2d70..4bde6c2 100644 --- a/tests/test_chinese.py +++ b/tests/test_chinese.py @@ -1,4 +1,4 @@ -from wordfreq import tokenize, word_frequency +from wordfreq import tokenize, word_frequency, zipf_frequency import pytest @@ -80,8 +80,10 @@ def test_alternate_codes(): def test_unreasonably_long(): - # This crashed earlier versions of wordfreq + # This crashed earlier versions of wordfreq due to an overflow in + # exponentiation. We've now changed the sequence of operations so it + # will underflow instead. lots_of_ls = 'l' * 800 - assert word_frequency(lots_of_ls, 'zh') < 1e-300 + assert word_frequency(lots_of_ls, 'zh') == 0. assert zipf_frequency(lots_of_ls, 'zh') == 0.