Exemple #1
0
    def test_single_line_comment(self):
        expected = self.gen_default()
        expected["file_lines"] = 1
        expected["comments"] = 1
        expected["single_line_comment"] = 1

        self.assertEqual(expected, get_comment_stats("//hello", java_thing))
Exemple #2
0
    def test_code_with_comment_comment_having_bash(self):
        expected = self.gen_default()
        expected["code_with_comments"] = 1
        expected["code"] = 1
        expected["comments"] = 1
        expected["file_lines"] = 1

        self.assertEqual(expected,
                         get_comment_stats("cats # dogs.sh", yaml_thing))
Exemple #3
0
    def test_actual_file(self):
        expected = self.gen_default()
        expected["file_lines"] = 150
        expected["blank_lines"] = 27
        expected["code"] = 123

        self.assertEqual(
            expected, get_comment_stats(example_files_test_cases[0],
                                        yaml_thing))
Exemple #4
0
    def test_code_and_single_comment(self):
        expected = self.gen_default()
        expected["file_lines"] = 2
        expected["code"] = 1
        expected["comments"] = 1
        expected["single_line_comment"] = 1

        self.assertEqual(expected, get_comment_stats("cats\n#dogs",
                                                     yaml_thing))
Exemple #5
0
    def test_multi_line_comment(self):
        expected = self.gen_default()
        expected["file_lines"] = 3
        expected["comments"] = 3
        expected["multi_line_comment"] = 3
        expected["multi_line_comment_unique"] = 1

        self.assertEqual(
            expected,
            get_comment_stats("/*hello\nworld\nthis is a test*/", java_thing))
Exemple #6
0
    def test_actual_file_with_complex_script_tags(self):
        expected = self.gen_default()
        expected["file_lines"] = 119
        expected["blank_lines"] = 2
        expected["code"] = 117
        expected["bash"] = 1

        self.assertEqual(
            expected, get_comment_stats(example_files_test_cases[1],
                                        yaml_thing))
Exemple #7
0
    def test_multiline_comment(self):
        expected = self.gen_default()
        expected["file_lines"] = 6
        expected["comments"] = 5
        expected["code"] = 1
        expected["multi_line_comment"] = 5
        expected["multi_line_comment_unique"] = 2

        self.assertEqual(
            expected,
            get_comment_stats(
                "# hello world\n#cats\n#dogs\nfoo bar\n# another testt\n#foo",
                yaml_thing))
Exemple #8
0
    def test_todo_comment(self):
        expected = self.gen_default()
        expected["file_lines"] = 11
        expected["blank_lines"] = 2
        expected["code"] = 8
        expected["code_with_comments"] = 1
        expected["todo"] = 1
        expected["comments"] = 2
        expected["single_line_comment"] = 1

        self.assertEqual(
            expected,
            get_comment_stats(
                """
go:
- 1.12
language: go # woo I am a comment
os:
- linux
- osx
script:
- go test -v
#TODO: I am a todo 
""", yaml_thing))
Exemple #9
0
 def test_none(self):
     expected = self.gen_default()
     expected["file_lines"] = 1
     expected["code"] = 1
     self.assertEqual(expected, get_comment_stats("cats", yaml_thing))
Exemple #10
0
 def test_basic(self):
     expected = self.gen_default()
     expected["file_lines"] = 1
     expected["comments"] = 1
     expected["single_line_comment"] = 1
     self.assertEqual(expected, get_comment_stats("#hello", yaml_thing))