<commit_before><?php class ClientSideCompilerTest extends PHPUnit_Framework_TestCase {

public function setup() {
	removeTestApp();
	createTestApp();
	require_once(GTROOT . "/Framework/ClientSideCompiler.php");
}

public function tearDown() {
	removeTestApp();
}

private function putApprootFileContents($fileArray /*, [$fileArrayN ..] */ ) {
	$fileArrayArray = func_get_args();
	foreach ($fileArrayArray as $fileArray) {
		if(array_keys($fileArray) !== range(0, count($fileArray) - 1)) {
			// Array is associative.
			foreach ($fileArray as $file => $content) {
				$filePath = APPROOT . $file;
				if(!is_dir(dirname($filePath))) {
					mkdir(dirname($filePath), 0775, true);
				}
				file_put_contents($filePath, $content);
			}
		}
		else {
			// Array is not associative.
			foreach ($fileArray as $file) {
				$filePath = APPROOT . $file;
				if(!is_dir(dirname($filePath))) {
					mkdir(dirname($filePath), 0775, true);
				}
				touch($filePath);
			}
		}
	}		
}

/**
 * Shorthand function that creates physical source files within APPROOT, fills
 * with the given contents, and also runs assertions of expected contents
 * against the processed files' contents.
 */
private function makeAssetAssertions($approotFileAssertionArray) {
	foreach ($approotFileAssertionArray as $approotFile => $contentsArray) {
		$sourceContents = is_array($contentsArray)
			? $contentsArray[0]
			: $contentsArray;

		$this->putApprootFileContents([$approotFile => $sourceContents]);

		if(is_array($contentsArray)) {
			$processed = ClientSideCompiler::process(APPROOT . $approotFile);

			// Allow testing arrays and regexes.
			if(is_array($contentsArray[1])) {
				foreach ($contentsArray[1] as $contentToCheck) {
					$this->assertContains($contentToCheck, $processed);
				}
			}
			else if(preg_match("/^\/.*\/[a-z]*$/", $contentsArray[1])) {
				$this->assertRegExp($contentsArray[1], $processed);
			}
			else {
				$this->assertContains($contentsArray[1], $processed);
			}
		}
	}
}

/**
 * The process function on the ClientSideCompiler calls a process function
 * according to  the file extension. Scss should use the SassParser class.
 */
public function testProcessScss() {
	$this->makeAssetAssertions([
		"/Style/Main.scss" => [
			"\$red = rgba(red, 0.8);
			body {
				> h1 {
					color: \$red;
				}
			}", "body > h1 {"],

		"/Style/InnerDir/IncludeMe.scss" => [
			"a#special {
				background: lighten(blue, 1.5);
			}", "a#special"],

		"/Style/Includer.scss" =>
			"@import InnerDir/IncludeMe;
			div.container {
				background: blue;
			}",
	]);
}

/**
 * The process function on the ClientSideCompiler calls a process function
 * according to  the file extension. Sass should use the SassParser class.
 */
public function testProcessSass() {
	$this->makeAssetAssertions([
		"/Style/Main.sass" => [
			"#main
				color: blue
				font-size: 0.3em", "#main {"],
	]);<commit_msg>Drop SASS support (not SCSS).<commit_after><?php class ClientSideCompilerTest extends PHPUnit_Framework_TestCase {

public function setup() {
	removeTestApp();
	createTestApp();
	require_once(GTROOT . "/Framework/ClientSideCompiler.php");
}

public function tearDown() {
	removeTestApp();
}

private function putApprootFileContents($fileArray /*, [$fileArrayN ..] */ ) {
	$fileArrayArray = func_get_args();
	foreach ($fileArrayArray as $fileArray) {
		if(array_keys($fileArray) !== range(0, count($fileArray) - 1)) {
			// Array is associative.
			foreach ($fileArray as $file => $content) {
				$filePath = APPROOT . $file;
				if(!is_dir(dirname($filePath))) {
					mkdir(dirname($filePath), 0775, true);
				}
				file_put_contents($filePath, $content);
			}
		}
		else {
			// Array is not associative.
			foreach ($fileArray as $file) {
				$filePath = APPROOT . $file;
				if(!is_dir(dirname($filePath))) {
					mkdir(dirname($filePath), 0775, true);
				}
				touch($filePath);
			}
		}
	}		
}

/**
 * Shorthand function that creates physical source files within APPROOT, fills
 * with the given contents, and also runs assertions of expected contents
 * against the processed files' contents.
 */
private function makeAssetAssertions($approotFileAssertionArray) {
	foreach ($approotFileAssertionArray as $approotFile => $contentsArray) {
		$sourceContents = is_array($contentsArray)
			? $contentsArray[0]
			: $contentsArray;

		$this->putApprootFileContents([$approotFile => $sourceContents]);

		if(is_array($contentsArray)) {
			$processed = ClientSideCompiler::process(APPROOT . $approotFile);

			// Allow testing arrays and regexes.
			if(is_array($contentsArray[1])) {
				foreach ($contentsArray[1] as $contentToCheck) {
					$this->assertContains($contentToCheck, $processed);
				}
			}
			else if(preg_match("/^\/.*\/[a-z]*$/", $contentsArray[1])) {
				$this->assertRegExp($contentsArray[1], $processed);
			}
			else {
				$this->assertContains($contentsArray[1], $processed);
			}
		}
	}
}

/**
 * The process function on the ClientSideCompiler calls a process function
 * according to  the file extension. Scss should use the SassParser class.
 */
public function testProcessScss() {
	$this->makeAssetAssertions([
		"/Style/Main.scss" => [
			"\$red: rgba(red, 0.8);
			body {
				> h1 {
					color: \$red;
				}
			}", "body > h1 {"],

		"/Style/InnerDir/IncludeMe.scss" => [
			"a#special {
				background: lighten(blue, 1.5);
			}", "a#special"],

		"/Style/Includer.scss" =>
			"@import InnerDir/IncludeMe;
			div.container {
				background: blue;
			}",
	]);
{'fraction_non_alphanumeric': 0.1533406352683461, 'fraction_numerical': 0.008397225264695144, 'mean_word_length': 3.8529672276350753, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4927459', 'n_tokens_mistral': 2083, 'n_tokens_neox': 1761, 'n_words': 386}