Fix ternary indent bug (#577)

* Add test.js files back to source control

* Fix ternary indent bug (#564)
master
Alex Rattray 2017-02-02 10:37:59 -08:00 committed by Christopher Chedeau
parent 69b7bd3fa8
commit 86d1264097
4 changed files with 55 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,3 +1,2 @@
node_modules
npm-debug.log
test.js

View File

@ -774,10 +774,10 @@ function genericPrintNoParens(path, options, print) {
concat([
line,
"? ",
indent(options.tabWidth, path.call(print, "consequent")),
indent(2, path.call(print, "consequent")),
line,
": ",
indent(options.tabWidth, path.call(print, "alternate"))
indent(2, path.call(print, "alternate"))
])
)
])

View File

@ -49,3 +49,55 @@ const obj5 = conditionIsTruthy
};
"
`;
exports[`test test.js 2`] = `
"const obj0 = conditionIsTruthy ? shortThing : otherShortThing
const obj1 = conditionIsTruthy ? { some: \'long\', object: \'with\', lots: \'of\', stuff } : shortThing
const obj2 = conditionIsTruthy ? shortThing : { some: \'long\', object: \'with\', lots: \'of\', stuff }
const obj3 = conditionIsTruthy ? { some: \'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\', object: \'with\', lots: \'of\', stuff } : shortThing
const obj4 = conditionIsTruthy ? shortThing : { some: \'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\', object: \'with\', lots: \'of\', stuff }
const obj5 = conditionIsTruthy ? { some: \'long\', object: \'with\', lots: \'of\', stuff } : { some: \'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\', object: \'with\', lots: \'of\', stuff }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const obj0 = conditionIsTruthy ? shortThing : otherShortThing;
const obj1 = conditionIsTruthy
? { some: \"long\", object: \"with\", lots: \"of\", stuff }
: shortThing;
const obj2 = conditionIsTruthy
? shortThing
: { some: \"long\", object: \"with\", lots: \"of\", stuff };
const obj3 = conditionIsTruthy
? {
some: \"eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\",
object: \"with\",
lots: \"of\",
stuff
}
: shortThing;
const obj4 = conditionIsTruthy
? shortThing
: {
some: \"eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\",
object: \"with\",
lots: \"of\",
stuff
};
const obj5 = conditionIsTruthy
? { some: \"long\", object: \"with\", lots: \"of\", stuff }
: {
some: \"eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\",
object: \"with\",
lots: \"of\",
stuff
};
"
`;

View File

@ -1 +1,2 @@
run_spec(__dirname);
run_spec(__dirname, { tabWidth: 4 });