RubySassCompiler implements AutoCloseable, SassCompiler { @Override public String compileString(String input, String includeDirName) throws RubySassCompilerException { return compileString(input, "", includeDirName, false); } RubySassCompiler();  RubySassCompiler(int precision);  RubySassCompiler(
			String compileMode, int compilerThreshold, int precision,
			String tmpDirName); @Override void close(); @Override String compileFile(String inputFileName, String includeDirName); @Override String compileFile(
			String inputFileName, String includeDirName,
			boolean generateSourceMap); @Override String compileFile(
			String inputFileName, String includeDirName,
			boolean generateSourceMap, String sourceMapFileName); @Override String compileString(String input, String includeDirName); @Override String compileString(
			String input, String inputFileName, String includeDirName,
			boolean generateSourceMap); @Override String compileString(
			String input, String inputFileName, String includeDirName,
			boolean generateSourceMap, String sourceMapFileName);  }
@Test public void testBoxShadowTransparent() throws Exception { try (SassCompiler sassCompiler = new RubySassCompiler()) { String expectedOutput = "foo { box-shadow: 2px 4px 7px rgba(0, 0, 0, 0.5); }"; String actualOutput = sassCompiler.compileString( "foo { box-shadow: 2px 4px 7px rgba(0, 0, 0, 0.5); }", ""); Assert.assertEquals( stripNewLines(expectedOutput), stripNewLines(actualOutput)); } }
@Test public void testCompileString() throws Exception { try (SassCompiler sassCompiler = new RubySassCompiler()) { String expectedOutput = "foo { margin: 42px; }"; String actualOutput = sassCompiler.compileString( "foo { margin: 21px * 2; }", ""); Assert.assertEquals( stripNewLines(expectedOutput), stripNewLines(actualOutput)); } }
@Test public void testCompileStringSassVariableWithUnicode() throws Exception { try (SassCompiler sassCompiler = new RubySassCompiler()) { File inputDir = new File( "../sass-compiler-jni/test-classes/unit/com/liferay/sass" + "/compiler/jni/internal/dependencies/"); File inputFile = new File(inputDir, "/unicode/input.scss"); String input = read(inputFile.toPath()); String actualOutput = sassCompiler.compileString(input, ""); Assert.assertNotNull(actualOutput); File expectedOutputFile = new File( inputDir, "/unicode/expected_output.css"); String expectedOutput = read(expectedOutputFile.toPath()); Assert.assertEquals( stripNewLines(expectedOutput), stripNewLines(actualOutput)); } }
@Test public void testCompileStringWithSourceMap() throws Exception { try (SassCompiler sassCompiler = new RubySassCompiler()) { File inputDir = new File( "../sass-compiler-jni/test-classes/unit/com/liferay/sass" + "/compiler/jni/internal/dependencies/sass-spec/14_imports"); File sourceMapFile = new File(inputDir, "input.css.map"); sourceMapFile.deleteOnExit(); Assert.assertFalse(sourceMapFile.exists()); File inputFile = new File(inputDir, "input.scss"); String input = read(inputFile.toPath()); String actualOutput = sassCompiler.compileString( input, inputFile.getCanonicalPath(), "", true); Assert.assertNotNull(actualOutput); Assert.assertTrue(sourceMapFile.exists()); File expectedOutputFile = new File( "../sass-compiler-jni/test-classes/unit/com/liferay/sass" + "/compiler/jni/internal/dependencies/sourcemap", "expected_output.css"); String expectedOutput = read(expectedOutputFile.toPath()); Assert.assertEquals( stripNewLines(expectedOutput), stripNewLines(actualOutput)); } }
@Test public void testSassPrecision() throws Exception { try (SassCompiler sassCompiler = new RubySassCompiler(10)) { String expectedOutput = ".foo { line-height: 1.428571429; }"; String actualOutput = sassCompiler.compileString( "$val: 1.428571429;.foo { line-height: $val; }", ""); Assert.assertEquals( stripNewLines(expectedOutput), stripNewLines(actualOutput)); } try (SassCompiler sassCompiler = new RubySassCompiler(3)) { String expectedOutput = ".foo { line-height: 1.429; }"; String actualOutput = sassCompiler.compileString( "$val: 1.428571429;.foo { line-height: $val; }", ""); Assert.assertEquals( stripNewLines(expectedOutput), stripNewLines(actualOutput)); } }