JniSassCompiler implements SassCompiler { @Override public String compileString(String input, String includeDirName) throws JniSassCompilerException { return compileString(input, "", includeDirName, false); } JniSassCompiler();  JniSassCompiler(int precision);  JniSassCompiler(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 testCompileString() throws Exception { SassCompiler sassCompiler = new JniSassCompiler(); 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 { SassCompiler sassCompiler = new JniSassCompiler(); Class<?> clazz = getClass(); URL url = clazz.getResource("dependencies"); File inputDir = new File(url.toURI()); 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 { SassCompiler sassCompiler = new JniSassCompiler(); Class<?> clazz = getClass(); URL url = clazz.getResource("dependencies"); File inputDir = new File(url.toURI()); File inputFile = new File(inputDir, "/sass-spec/14_imports/input.scss"); File sourceMapFile = new File( inputDir, "/sass-spec/14_imports/input.css.map"); sourceMapFile.deleteOnExit(); Assert.assertFalse(sourceMapFile.exists()); String input = read(inputFile.toPath()); String actualOutput = sassCompiler.compileString( input, inputFile.getCanonicalPath(), "", true); Assert.assertNotNull(actualOutput); Assert.assertTrue(sourceMapFile.exists()); File expectedOutputFile = new File( inputDir, "/sourcemap/expected_output.css"); String expectedOutput = read(expectedOutputFile.toPath()); Assert.assertEquals( stripNewLines(expectedOutput), stripNewLines(actualOutput)); }
@Test public void testSassPrecision() throws Exception { SassCompiler sassCompiler = new JniSassCompiler(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)); sassCompiler = new JniSassCompiler(3); expectedOutput = ".foo { line-height: 1.429; }"; actualOutput = sassCompiler.compileString( "$val: 1.428571429;.foo { line-height: $val; }", ""); Assert.assertEquals( stripNewLines(expectedOutput), stripNewLines(actualOutput)); }
@Test public void testBoxShadowTransparent() throws Exception { SassCompiler sassCompiler = new JniSassCompiler(); 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)); }