diff --git a/js/test/beautify-tests.js b/js/test/beautify-tests.js index e254f3e17..87d8eba24 100755 --- a/js/test/beautify-tests.js +++ b/js/test/beautify-tests.js @@ -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()}', diff --git a/python/jsbeautifier/tests/testjsbeautifier.py b/python/jsbeautifier/tests/testjsbeautifier.py index 780f784da..094aea0b7 100644 --- a/python/jsbeautifier/tests/testjsbeautifier.py +++ b/python/jsbeautifier/tests/testjsbeautifier.py @@ -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 }',