Add initial tests

This commit is contained in:
Liam Newman 2019-03-20 13:50:41 -07:00
parent e42c24c007
commit 6db4a03841
3 changed files with 115 additions and 0 deletions

View File

@ -7081,6 +7081,39 @@ function run_javascript_tests(test_obj, Urlencoded, js_beautify, html_beautify,
'}');
//============================================================
// preserve_empty_lines_indent true
reset_options();
set_name('preserve_empty_lines_indent true');
opts.preserve_empty_lines_indent = true;
test_fragment(
'var a = 1;\n' +
'\n' +
'var b = 1;');
test_fragment(
'var a = 1;\n' +
' \n' +
'var b = 1;',
// -- output --
'var a = 1;\n' +
'\n' +
'var b = 1;');
test_fragment(
'{\n' +
' var a = 1;\n' +
' \n' +
' var b = 1;\n' +
'\n' +
'}',
// -- output --
'{\n' +
' var a = 1;\n' +
' \n' +
' var b = 1;\n' +
' \n' +
'}');
//============================================================
// Old tests
reset_options();

View File

@ -6805,6 +6805,38 @@ class TestJSBeautifier(unittest.TestCase):
'}')
#============================================================
# preserve_empty_lines_indent true
self.reset_options()
self.options.preserve_empty_lines_indent = true
test_fragment(
'var a = 1;\n' +
'\n' +
'var b = 1;')
test_fragment(
'var a = 1;\n' +
' \n' +
'var b = 1;',
# -- output --
'var a = 1;\n' +
'\n' +
'var b = 1;')
test_fragment(
'{\n' +
' var a = 1;\n' +
' \n' +
' var b = 1;\n' +
'\n' +
'}',
# -- output --
'{\n' +
' var a = 1;\n' +
' \n' +
' var b = 1;\n' +
' \n' +
'}')
#============================================================
# Old tests
self.reset_options()

View File

@ -4482,6 +4482,56 @@ exports.test_data = {
// ]
// }
]
}, {
name: "preserve_empty_lines_indent true",
description: "",
options: [
{ name: "preserve_empty_lines_indent", value: "true" }
],
// NOTE: all of these tests must be "fragment: true", so that the
// test framework doesn't try additional permutations based
// on these inputs.
tests: [{
fragment: true,
unchanged: [
'var a = 1;',
'',
'var b = 1;'
]
},
{
fragment: true,
input: [
'var a = 1;',
' ',
'var b = 1;'
],
output: [
'var a = 1;',
'',
'var b = 1;'
]
},
{
fragment: true,
input: [
'{',
' var a = 1;',
' ',
' var b = 1;',
'',
'}'
],
output: [
'{',
' var a = 1;',
' ',
' var b = 1;',
' ',
'}'
]
}
]
}, {
// =======================================================
// New tests groups should be added above this line.