Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incomplete list of non-positionable operators (python lib) #878

Merged
merged 2 commits into from
Feb 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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