| 1 | #!/usr/bin/env python2
 | 
| 2 | """spelling_test.py: Tests for spelling.py."""
 | 
| 3 | from __future__ import print_function
 | 
| 4 | 
 | 
| 5 | import unittest
 | 
| 6 | 
 | 
| 7 | import spelling  # module under test
 | 
| 8 | 
 | 
| 9 | 
 | 
| 10 | class SpellingTest(unittest.TestCase):
 | 
| 11 | 
 | 
| 12 |     def testSplitWords(self):
 | 
| 13 | 
 | 
| 14 |         docs = [
 | 
| 15 |             r'''
 | 
| 16 |         a b c   # single chars left out
 | 
| 17 |         foo bar
 | 
| 18 |         http://google.com   # url stripped
 | 
| 19 |         spam
 | 
| 20 | 
 | 
| 21 |         https://google.com/?q=foo 
 | 
| 22 |         file:///home/andy/git
 | 
| 23 | 
 | 
| 24 |         aren't
 | 
| 25 |         can't
 | 
| 26 | 
 | 
| 27 |         array[r'\']
 | 
| 28 | 
 | 
| 29 |         ''',
 | 
| 30 | 
 | 
| 31 |             # real test case from lynx -dump
 | 
| 32 |             '''
 | 
| 33 |         hi
 | 
| 34 |         9. file:///home/andy/git/oilshell/oil/_release/VERSION/doc/oil-language-faq.html#why-doesnt-a-raw-string-work-here-arrayr
 | 
| 35 | 
 | 
| 36 |         bye
 | 
| 37 | 
 | 
| 38 |         aren'tzzz
 | 
| 39 |         '''
 | 
| 40 | 
 | 
| 41 |             # turns into "aren't", "zzz" which I guess is right
 | 
| 42 |         ]
 | 
| 43 | 
 | 
| 44 |         for doc in docs:
 | 
| 45 |             print(list(spelling.SplitWords(doc)))
 | 
| 46 | 
 | 
| 47 | 
 | 
| 48 | if __name__ == '__main__':
 | 
| 49 |     unittest.main()
 |