diff options
| author | Sean Brant | 2013-03-09 15:57:26 -0600 | 
|---|---|---|
| committer | Sean Brant | 2013-03-09 15:57:26 -0600 | 
| commit | fa90f078e5de5a1acbd9eda529db17ab1b2b4cb3 (patch) | |
| tree | 7d3014b692f53e5272c52a7f87c66f5aa9908b44 /tests/test_comment.py | |
| download | pykss-fa90f078e5de5a1acbd9eda529db17ab1b2b4cb3.tar.bz2 | |
Initial Import
Diffstat (limited to 'tests/test_comment.py')
| -rw-r--r-- | tests/test_comment.py | 65 | 
1 files changed, 65 insertions, 0 deletions
| diff --git a/tests/test_comment.py b/tests/test_comment.py new file mode 100644 index 0000000..ea47156 --- /dev/null +++ b/tests/test_comment.py @@ -0,0 +1,65 @@ +import os +import unittest + +from pykss import comment + + +class CommentMethodTestCase(unittest.TestCase): + +    def test_detects_single_line_comment_syntax(self): +        self.assertTrue(comment.is_single_line_comment('// yuuuuup')) +        self.assertFalse(comment.is_single_line_comment('nooooope')) + +    def test_detects_start_of_multi_line_comment_syntax(self): +        self.assertTrue(comment.is_multi_line_comment_start('/* yuuuuup')) +        self.assertFalse(comment.is_multi_line_comment_start('nooooope')) + +    def test_detects_end_of_multi_line_comment_syntax(self): +        self.assertTrue(comment.is_multi_line_comment_end(" yuuuuup */")) +        self.assertFalse(comment.is_multi_line_comment_end("nooooope")) + +    def test_parses_the_single_line_comment_syntax(self): +        self.assertEqual(comment.parse_single_line("// yuuuuup"), 'yuuuuup') + +    def test_parses_the_multi_line_comment_syntax(self): +        self.assertEqual(comment.parse_multi_line('/* yuuuup */'), 'yuuuup') + + +class CommentParserTestCase(unittest.TestCase): + +    def setUp(self): +        text = os.path.join(os.path.dirname(__file__), 'fixtures', 'comments.txt') +        self.comments = comment.CommentParser(text).blocks + +    def test_finds_single_line_comment_styles(self): +        expected = """ +This comment block has comment identifiers on every line. + +Fun fact: this is Kyle's favorite comment syntax!""" +        self.assertTrue(expected.strip() in self.comments) + +    def test_finds_block_style_comment_styles(self): +        expected = """ +This comment block is a block-style comment syntax. + +There's only two identifier across multiple lines. +        """ +        self.assertTrue(expected.strip() in self.comments) + +        expected = """ +This is another common multi-line comment style. + +It has stars at the begining of every line. +        """ +        self.assertTrue(expected.strip() in self.comments) + +    def test_handles_mixed_styles(self): +        expected = "This comment has a /* comment */ identifier inside of it!" +        self.assertTrue(expected.strip() in self.comments) + +        expected = 'Look at my //cool// comment art!' +        self.assertTrue(expected.strip() in self.comments) + +    def test_handles_indented_comments(self): +        self.assertTrue('Indented single-line comment.' in self.comments) +        self.assertTrue('Indented block comment.' in self.comments) | 
