Tests for spaces inside square bracket support

Introduced but not tested as part of #235.
Closes #126.
This commit is contained in:
Liam Newman 2013-04-25 11:47:06 -07:00
parent a1fa05c4b0
commit 82e18999a1
2 changed files with 24 additions and 0 deletions

View File

@ -916,6 +916,12 @@ function run_beautifier_tests(test_obj, Urlencoded, js_beautify)
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}');
bt('a=[];',
'a = [];');
bt('a=[b,c,d];',
'a = [b, c, d];');
bt('a= f[b];',
'a = f[b];');
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 }',
@ -923,6 +929,12 @@ function run_beautifier_tests(test_obj, Urlencoded, js_beautify)
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}');
bt('a=[ ];',
'a = [ ];');
bt('a=[b,c,d];',
'a = [ b, c, d ];');
bt('a= f[b];',
'a = f[ b ];');
opts.space_in_paren = false;
// Test that e4x literals passed through when e4x-option is enabled

View File

@ -851,6 +851,12 @@ class TestJSBeautifier(unittest.TestCase):
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}');
bt('a=[];',
'a = [];');
bt('a=[b,c,d];',
'a = [b, c, d];');
bt('a= f[b];',
'a = f[b];');
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 }',
@ -858,6 +864,12 @@ class TestJSBeautifier(unittest.TestCase):
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}');
bt('a=[ ];',
'a = [ ];');
bt('a=[b,c,d];',
'a = [ b, c, d ];');
bt('a= f[b];',
'a = f[ b ];');
self.options.space_in_paren = False