Skip to content

Commit 7418926

Browse files
committed
added more unit tests for different command line arguments, fixes #28
1 parent 68fe482 commit 7418926

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

fprettify/tests/__init__.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,36 @@ def test_nested(self):
186186
self.assert_fprettify_result([], instring, outstring_exp_default)
187187
self.assert_fprettify_result(['--strict-indent'], instring, outstring_exp_strict)
188188

189+
def test_disable(self):
190+
"""test disabling indentation and/or whitespace formatting"""
191+
instring = ("if(&\nl==111)&\n then\n do m =1, 2\n A=&\nB+C\n enddo; endif")
192+
outstring_exp_default = ("if ( &\n l == 111) &\n then\n do m = 1, 2\n"
193+
" A = &\n B + C\n enddo; endif")
194+
outstring_exp_nowhitespace = ("if(&\n l==111)&\n then\n do m =1, 2\n"
195+
" A=&\n B+C\n enddo; endif")
196+
outstring_exp_noindent = ("if ( &\nl == 111) &\n then\n do m = 1, 2\n"
197+
" A = &\nB + C\n enddo; endif")
198+
199+
self.assert_fprettify_result([], instring, outstring_exp_default)
200+
self.assert_fprettify_result(['--disable-whitespace'], instring, outstring_exp_nowhitespace)
201+
self.assert_fprettify_result(['--disable-indent'], instring, outstring_exp_noindent)
202+
self.assert_fprettify_result(['--disable-indent', '--disable-whitespace'], instring, instring)
203+
204+
def test_comments(self):
205+
"""test options related to comments"""
206+
instring = ("TYPE mytype\n! c1\n !c2\n INTEGER :: a ! c3\n"
207+
" REAL :: b, & ! c4\n! c5\n ! c6\n"
208+
" d ! c7\nEND TYPE ! c8")
209+
outstring_exp_default = ("TYPE mytype\n! c1\n !c2\n INTEGER :: a ! c3\n"
210+
" REAL :: b, & ! c4\n ! c5\n ! c6\n"
211+
" d ! c7\nEND TYPE ! c8")
212+
outstring_exp_strip = ("TYPE mytype\n! c1\n !c2\n INTEGER :: a ! c3\n"
213+
" REAL :: b, & ! c4\n ! c5\n ! c6\n"
214+
" d ! c7\nEND TYPE ! c8")
215+
216+
self.assert_fprettify_result([], instring, outstring_exp_default)
217+
self.assert_fprettify_result(['--strip-comments'], instring, outstring_exp_strip)
218+
189219
def test_directive(self):
190220
"""
191221
test deactivate directives '!&' (inline) and '!&<', '!&>' (block)

0 commit comments

Comments
 (0)