corrade-nucleus-nucleons – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
2 | office | 1 | import re |
2 | import unittest |
||
3 | import jsbeautifier |
||
4 | |||
5 | class TestJSBeautifierIndentation(unittest.TestCase): |
||
6 | def test_tabs(self): |
||
7 | test_fragment = self.decodesto |
||
8 | |||
9 | self.options.indent_with_tabs = 1; |
||
10 | test_fragment('{tabs()}', "{\n\ttabs()\n}"); |
||
11 | |||
12 | def test_function_indent(self): |
||
13 | test_fragment = self.decodesto |
||
14 | |||
15 | self.options.indent_with_tabs = 1; |
||
16 | self.options.keep_function_indentation = 1; |
||
17 | test_fragment('var foo = function(){ bar() }();', "var foo = function() {\n\tbar()\n}();"); |
||
18 | |||
19 | self.options.tabs = 1; |
||
20 | self.options.keep_function_indentation = 0; |
||
21 | test_fragment('var foo = function(){ baz() }();', "var foo = function() {\n\tbaz()\n}();"); |
||
22 | |||
23 | def decodesto(self, input, expectation=None): |
||
24 | self.assertEqual( |
||
25 | jsbeautifier.beautify(input, self.options), expectation or input) |
||
26 | |||
27 | @classmethod |
||
28 | def setUpClass(cls): |
||
29 | options = jsbeautifier.default_options() |
||
30 | options.indent_size = 4 |
||
31 | options.indent_char = ' ' |
||
32 | options.preserve_newlines = True |
||
33 | options.jslint_happy = False |
||
34 | options.keep_array_indentation = False |
||
35 | options.brace_style = 'collapse' |
||
36 | options.indent_level = 0 |
||
37 | |||
38 | cls.options = options |
||
39 | cls.wrapregex = re.compile('^(.+)$', re.MULTILINE) |
||
40 | |||
41 | |||
42 | if __name__ == '__main__': |
||
43 | unittest.main() |