/** Creates a harness for testing a formatter whose steps don't depend on the file. */ public static StepHarness forFormatter(Formatter formatter) { return new StepHarness(FormatterFunc.Closeable.of( formatter::close, input -> formatter.compute(input, new File("")))); }
/** Creates a harness for testing steps which don't depend on the file. */ public static StepHarness forStep(FormatterStep step) { // We don't care if an individual FormatterStep is misbehaving on line-endings, because // Formatter fixes that. No reason to care in tests either. It's likely to pop up when // running tests on Windows from time-to-time return new StepHarness(FormatterFunc.Closeable.of( () -> { if (step instanceof FormatterStepImpl.Standard) { ((FormatterStepImpl.Standard<?>) step).cleanupFormatterFunc(); } }, input -> LineEnding.toUnix(step.format(input, new File(""))))); }
return FormatterFunc.Closeable.of(() -> { asList(formatResultCallback, formatterOptions, tsFmt, nodeJSWrapper).forEach(ReflectiveObjectWrapper::release); }, input -> {
return FormatterFunc.Closeable.of(() -> { asList(prettierConfig, prettier, nodeJSWrapper).forEach(ReflectiveObjectWrapper::release); }, input -> {