forked from merlinthered/sublime-rainmeter
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work on rewriting the indention plugin
- Loading branch information
Showing
2 changed files
with
171 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
"""This module is for testing the indent rainmeter module.""" | ||
|
||
|
||
import sys | ||
|
||
from unittest import TestCase | ||
|
||
INDENT = sys.modules["Rainmeter.indentrainmeter"] | ||
|
||
|
||
def indention_depth_from_initial(line): | ||
return INDENT.calc_line_indention_depth(line, INDENT.IndentType.Initial, 0) | ||
|
||
|
||
def indention_depth_from_fold_marker(line): | ||
return INDENT.calc_line_indention_depth(line, INDENT.IndentType.FoldMarker, 1) | ||
|
||
|
||
def indention_depth_from_section(line): | ||
return INDENT.calc_line_indention_depth(line, INDENT.IndentType.Section, 1) | ||
|
||
|
||
class TestCalcLineIndentionDepthFromInitial(TestCase): | ||
""".""" | ||
|
||
def test_with_empty_line(self): | ||
line = "" | ||
indention_depth = indention_depth_from_initial(line) | ||
self.assertEqual(indention_depth, (0, INDENT.IndentType.Initial, 0)) | ||
|
||
def test_with_comment(self): | ||
line = "; This is a comment" | ||
indention_depth = indention_depth_from_initial(line) | ||
self.assertEqual(indention_depth, (0, INDENT.IndentType.Initial, 0)) | ||
|
||
def test_with_fold_marker(self): | ||
line = ";; This is a fold marker" | ||
indention_depth = indention_depth_from_initial(line) | ||
self.assertEqual(indention_depth, (0, INDENT.IndentType.FoldMarker, 1)) | ||
|
||
def test_with_section(self): | ||
line = "[Section]" | ||
indention_depth = indention_depth_from_initial(line) | ||
self.assertEqual(indention_depth, (0, INDENT.IndentType.Section, 1)) | ||
|
||
def test_with_key_value(self): | ||
line = "Key = Value" | ||
indention_depth = indention_depth_from_initial(line) | ||
self.assertEqual(indention_depth, (0, INDENT.IndentType.Initial, 0)) | ||
|
||
|
||
class TestCalcLineIndentionDepthFromFoldMarker(TestCase): | ||
""".""" | ||
|
||
def test_with_empty_line(self): | ||
line = "" | ||
indention_depth = indention_depth_from_fold_marker(line) | ||
self.assertEqual(indention_depth, (0, INDENT.IndentType.FoldMarker, 1)) | ||
|
||
def test_with_comment(self): | ||
line = "; This is a comment" | ||
indention_depth = indention_depth_from_fold_marker(line) | ||
self.assertEqual(indention_depth, (1, INDENT.IndentType.FoldMarker, 1)) | ||
|
||
def test_with_fold_marker(self): | ||
line = ";; This is a fold marker" | ||
indention_depth = indention_depth_from_fold_marker(line) | ||
self.assertEqual(indention_depth, (0, INDENT.IndentType.FoldMarker, 1)) | ||
|
||
def test_with_section(self): | ||
line = "[Section]" | ||
indention_depth = indention_depth_from_fold_marker(line) | ||
self.assertEqual(indention_depth, (1, INDENT.IndentType.Section, 2)) | ||
|
||
def test_with_key_value(self): | ||
line = "Key = Value" | ||
indention_depth = indention_depth_from_fold_marker(line) | ||
self.assertEqual(indention_depth, (1, INDENT.IndentType.FoldMarker, 1)) | ||
|
||
|
||
class TestCalcLineIndentionDepthFromSection(TestCase): | ||
""".""" | ||
|
||
def test_with_empty_line(self): | ||
line = "" | ||
indention_depth = indention_depth_from_section(line) | ||
self.assertEqual(indention_depth, (0, INDENT.IndentType.Section, 1)) | ||
|
||
def test_with_comment(self): | ||
line = "; This is a comment" | ||
indention_depth = indention_depth_from_section(line) | ||
self.assertEqual(indention_depth, (1, INDENT.IndentType.Section, 1)) | ||
|
||
def test_with_fold_marker(self): | ||
line = ";; This is a fold marker" | ||
indention_depth = indention_depth_from_section(line) | ||
self.assertEqual(indention_depth, (0, INDENT.IndentType.FoldMarker, 1)) | ||
|
||
def test_with_section(self): | ||
line = "[Section]" | ||
indention_depth = indention_depth_from_section(line) | ||
self.assertEqual(indention_depth, (0, INDENT.IndentType.Section, 1)) | ||
|
||
def test_with_key_value(self): | ||
line = "Key = Value" | ||
indention_depth = indention_depth_from_section(line) | ||
self.assertEqual(indention_depth, (1, INDENT.IndentType.Section, 1)) |