Skip to content

Commit

Permalink
Merge pull request #878 from orottier/fix-non-positionable-ops
Browse files Browse the repository at this point in the history
Fix incomplete list of non-positionable operators (python lib)
  • Loading branch information
bitwiseman committed Feb 23, 2016
2 parents 0957ba4 + f557abb commit 7fa79e8
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
16 changes: 16 additions & 0 deletions js/test/generated/beautify-javascript-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2081,6 +2081,22 @@ function run_javascript_tests(test_obj, Urlencoded, js_beautify, html_beautify,
'].join("-");');


reset_options();
//============================================================
// Test non-positionable-ops
bt('a += 2;');
bt('a -= 2;');
bt('a *= 2;');
bt('a /= 2;');
bt('a %= 2;');
bt('a &= 2;');
bt('a ^= 2;');
bt('a |= 2;');
bt('a **= 2;');
bt('a <<= 2;');
bt('a >>= 2;');


reset_options();
//============================================================
// Destructured and related
Expand Down
2 changes: 1 addition & 1 deletion python/jsbeautifier/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ class Tokenizer:
positionable_operators = '!= !== % & && * ** + - / : < << <= == === > >= >> >>> ? ^ | ||'.split(' ')
punct = (positionable_operators +
# non-positionable operators - these do not follow operator position settings
'! %= &= *= ++ += , -- /= :: <<= = => >>= >>>= ^= |= ~'.split(' '))
'! %= &= *= **= ++ += , -- -= /= :: <<= = => >>= >>>= ^= |= ~'.split(' '))

# Words which always should start on a new line
line_starters = 'continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export'.split(',')
Expand Down
16 changes: 16 additions & 0 deletions python/jsbeautifier/tests/generated/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,22 @@ def unicode_char(value):
'].join("-");')


self.reset_options();
#============================================================
# Test non-positionable-ops
bt('a += 2;')
bt('a -= 2;')
bt('a *= 2;')
bt('a /= 2;')
bt('a %= 2;')
bt('a &= 2;')
bt('a ^= 2;')
bt('a |= 2;')
bt('a **= 2;')
bt('a <<= 2;')
bt('a >>= 2;')


self.reset_options();
#============================================================
# Destructured and related
Expand Down
16 changes: 16 additions & 0 deletions test/data/javascript/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,22 @@ exports.test_data = {
]
},
]
}, {
name: "Test non-positionable-ops",
description: "Ensure specific bugs do not recur",
tests: [
{ unchanged: 'a += 2;' },
{ unchanged: 'a -= 2;' },
{ unchanged: 'a *= 2;' },
{ unchanged: 'a /= 2;' },
{ unchanged: 'a %= 2;' },
{ unchanged: 'a &= 2;' },
{ unchanged: 'a ^= 2;' },
{ unchanged: 'a |= 2;' },
{ unchanged: 'a **= 2;' },
{ unchanged: 'a <<= 2;' },
{ unchanged: 'a >>= 2;' },
]
}, {
name: "Destructured and related",
description: "Ensure specific bugs do not recur",
Expand Down

0 comments on commit 7fa79e8

Please sign in to comment.