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

Object literal shorthand function formatting tests #942

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 8 additions & 0 deletions js/test/generated/beautify-javascript-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,14 @@ function run_javascript_tests(test_obj, Urlencoded, js_beautify, html_beautify,
bt('x ** -2');


reset_options();
//============================================================
// Object literal shorthand functions
bt('return {\n foo() {\n return 42;\n }\n}');
bt('var foo = {\n * bar() {\n yield 42;\n }\n};');
bt('var foo = {bar(){return 42;},*barGen(){yield 42;}};', 'var foo = {\n bar() {\n return 42;\n },\n * barGen() {\n yield 42;\n }\n};');


reset_options();
//============================================================
// End With Newline - (eof = "\n")
Expand Down
8 changes: 8 additions & 0 deletions python/jsbeautifier/tests/generated/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ def unicode_char(value):
bt('x ** -2')


self.reset_options();
#============================================================
# Object literal shorthand functions
bt('return {\n foo() {\n return 42;\n }\n}')
bt('var foo = {\n * bar() {\n yield 42;\n }\n};')
bt('var foo = {bar(){return 42;},*barGen(){yield 42;}};', 'var foo = {\n bar() {\n return 42;\n },\n * barGen() {\n yield 42;\n }\n};')


self.reset_options();
#============================================================
# End With Newline - (eof = "\n")
Expand Down
11 changes: 11 additions & 0 deletions test/data/javascript/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ exports.test_data = {
{ unchanged: 'x ** 2' },
{ unchanged: 'x ** -2' }
]
}, {
name: "Object literal shorthand functions",
description: "Object literal shorthand functions",
tests: [
{ unchanged: 'return {\n foo() {\n return 42;\n }\n}' },
{ unchanged: 'var foo = {\n * bar() {\n yield 42;\n }\n};' },
{
input: 'var foo = {bar(){return 42;},*barGen(){yield 42;}};',
output: "var foo = {\n bar() {\n return 42;\n },\n * barGen() {\n yield 42;\n }\n};"
}
]
}, {
name: "End With Newline",
description: "",
Expand Down