Skip to content

Commit

Permalink
Merge pull request #2 from bitwiseman/pad-in-paren
Browse files Browse the repository at this point in the history
Tests for space_in_paren false that match
  • Loading branch information
rasmuserik committed Apr 20, 2013
2 parents a4a1f8d + fd00a7e commit ed72853
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion js/test/beautify-tests.js
Expand Up @@ -906,10 +906,16 @@ function run_beautifier_tests(test_obj, Urlencoded, js_beautify)
'a = 1;\n\n\n\n\n\n\n\nb = 2;');

// Test the option to have spaces within parens
opts.space_in_paren = false;
bt('if(p) foo(a,b)', 'if (p) foo(a, b)');
bt('try{while(true){willThrow()}}catch(result)switch(result){case 1:++result }',
'try {\n while (true) {\n willThrow()\n }\n} catch (result) switch (result) {\n case 1:\n ++result\n}');
bt('((e/((a+(b)*c)-d))^2)*5;', '((e / ((a + (b) * c) - d)) ^ 2) * 5;');
bt('function f(a,b) {if(a) b()}function g(a,b) {if(!a) b()}',
'function f(a, b) {\n if (a) b()\n}\nfunction g(a, b) {\n if (!a) b()\n}');
opts.space_in_paren = true
bt('if(p) foo(a,b)', 'if ( p ) foo( a, b )');
bt('try{while(true){willThrow()}}catch(result)switch(result){case 1:++result }',
bt('try{while(true){willThrow()}}catch(result)switch(result){case 1:++result }',
'try {\n while ( true ) {\n willThrow( )\n }\n} catch ( result ) switch ( result ) {\n case 1:\n ++result\n}');
bt('((e/((a+(b)*c)-d))^2)*5;', '( ( e / ( ( a + ( b ) * c ) - d ) ) ^ 2 ) * 5;');
bt('function f(a,b) {if(a) b()}function g(a,b) {if(!a) b()}',
Expand Down
6 changes: 6 additions & 0 deletions python/jsbeautifier/tests/testjsbeautifier.py
Expand Up @@ -841,7 +841,13 @@ def test_beautifier(self):
'a = 1;\n\n\n\n\n\n\n\nb = 2;');

# Test the option to have spaces within parens
self.options.space_in_paren = False
bt('if(p) foo(a,b)', 'if (p) foo(a, b)');
bt('try{while(true){willThrow()}}catch(result)switch(result){case 1:++result }',
'try {\n while (true) {\n willThrow()\n }\n} catch (result) switch (result) {\n case 1:\n ++result\n}');
bt('((e/((a+(b)*c)-d))^2)*5;', '((e / ((a + (b) * c) - d)) ^ 2) * 5;');
bt('function f(a,b) {if(a) b()}function g(a,b) {if(!a) b()}',
'function f(a, b) {\n if (a) b()\n}\nfunction g(a, b) {\n if (!a) b()\n}');
self.options.space_in_paren = True
bt('if(p) foo(a,b)', 'if ( p ) foo( a, b )');
bt('try{while(true){willThrow()}}catch(result)switch(result){case 1:++result }',
Expand Down

0 comments on commit ed72853

Please sign in to comment.