<commit_before>part of forandar;

/// Custom Tests
class TempTests {

	final VirtualMachine vm;

	TempTests(VirtualMachine this.vm) {
	}

	header(String str, e, name) {
		window.console.info("\n>>>>>>TEST>>>>>> $str");

		print('"$name" $e');
	}

	footer(String str) {
		print("<<<<<<<<<<<<<<<< $str");
	}

	separator() {
		print("----------------");
	}
	

	/// Tests a [Stack] instance
	TestStack(Stack t, String name) {
		this.header("stack", t, name);
		print("length: ${t.data.length} cells, ${t.data.lengthInBytes} bytes");
		this.separator();

		t.Push(82); print("Push(82) >\t${t}");
		t.Push(25); print("Push(25) >\t${t}");
		t.Push(11); print("Push(11) >\t${t}");
		t.Push(3);  print("Push(11) >\t${t}");

		t.Rot(); print("Rot() >\t\t${t}");
		t.RotCC(); print("Rotcc() >\t${t}");

		t.Over(); print("Over() >\t${t}");
		print("Pop() > ${t.Pop()}\t${t}");
		t.Swap(); print("Swap() >\t${t}");
		t.Dup(); print("Dup() >\t\t${t}");

		t.Pick(4); print("Pick(4) >\t${t}");

		//t.Roll(4); print("Roll(4) >\t${t)}");

		t.Nip(); print("Nip() >\t\t${t}");
		print("Pop() > ${t.Pop()}\t${t}");
		t.Tuck(); print("Tuck() >\t${t}");

		this.footer("/stack");
	}

	/// Tests a [DataSpace] instance.
	TestDataSpace(DataSpace t, String name) {
		this.header("dataSpace", t, name);
		this.separator();
		this.footer("/dataSpace");
	}

	/// Tests a [Dictionary] instance.
	TestDictionary(Dictionary t, String name) {

		this.header("dictionary", t, name);
		print("nº words: ${t.wordsMap.length} in map, ${t.wordsList.length} in list");
		this.separator();

		// lists the words
		t.wordsMap.forEach( (key, value) {
			print("${value.st}\t${value.name}\t"
				"${value.isImmediate ? "[immediate]" : ""} "
				"${value.isCompileOnly ? "[compileOnly]" : ""} "
			);
		});
		this.separator();

		/// Tests some [dataStack] manipulation calling [Word]s from the [Dictionary] 
		t.wordsMap["OVER"].code(); print("OVER >\t\t${this.vm.dataStack}");
		t.wordsMap["?DUP"].code(); print("?DUP >\t\t${this.vm.dataStack}");
		


		this.footer("/dictionary");
	}

	/// TODO: Tests a [VirtualMachine] instance.
	TestVirtualMachine(VirtualMachine t, String name) {
		this.header("VirtualMachine", t, name);
		this.separator();
		this.footer("/VirtualMachine");
	}<commit_msg>improve tests; add wrappers for console printout<commit_after>part of forandar;

/// Custom Tests
class TempTests {

	final VirtualMachine vm;

	TempTests(VirtualMachine this.vm);

	/// Wraps console print for debug, info warn & error
	///
	/// https://api.dartlang.org/1.13.0/dart-html/Console-class.html
	printD(String s) => window.console.debug(s);
	printI(String s) => window.console.info(s);
	printW(String s) => window.console.warn(s);
	printE(String s) => window.console.error(s);

	header(String str, e, name) {
		print("");
		printI("\n");
		printD(">>>>>>TEST>>>>>> $str");
		printD('"$name" $e');
	}

	footer(String str) {
		printD("<<<<<<<<<<<<<<<< $str");
	}

	separator() {
		printD("----------------");
	}
	

	/// Tests a [Stack] instance
	TestStack(Stack t, String name) {
		this.header("stack", t, name);
		printD("length: ${t.data.length} cells, ${t.data.lengthInBytes} bytes");
		this.separator();

		t.Push(82); printD("Push(82) >\t${t}");
		t.Push(25); printD("Push(25) >\t${t}");
		t.Push(11); printD("Push(11) >\t${t}");
		t.Push(3);  printD("Push(11) >\t${t}");

		t.Rot(); printD("Rot() >\t\t${t}");
		t.RotCC(); printD("Rotcc() >\t${t}");

		t.Over(); printD("Over() >\t${t}");
		printD("Pop() > ${t.Pop()}\t${t}");
		t.Swap(); printD("Swap() >\t${t}");
		t.Dup(); printD("Dup() >\t\t${t}");

		t.Pick(4); printD("Pick(4) >\t${t}");

		//t.Roll(4); printD("Roll(4) >\t${t)}");

		t.Nip(); printD("Nip() >\t\t${t}");
		printD("Pop() > ${t.Pop()}\t${t}");
		t.Tuck(); printD("Tuck() >\t${t}");

		this.footer("/stack");
	}

	/// Tests a [DataSpace] instance.
	TestDataSpace(DataSpace t, String name) {
		this.header("dataSpace", t, name);
		this.separator();
		this.footer("/dataSpace");
	}

	/// Tests a [Dictionary] instance.
	TestDictionary(Dictionary t, String name) {

		this.header("dictionary", t, name);
		printD("nº words: ${t.wordsMap.length} in map, ${t.wordsList.length} in list");
		this.separator();

		// lists the words
		t.wordsMap.forEach( (key, value) {
			printD("${value.st}\t${value.name}\t"
				"${value.isImmediate ? "[immediate]" : ""} "
				"${value.isCompileOnly ? "[compileOnly]" : ""} "
			);
		});
		this.separator();

		/// Tests some [dataStack] manipulation calling [Word]s from the [Dictionary] 
		t.wordsMap["OVER"].code(); printD("OVER >\t\t${this.vm.dataStack}");
		t.wordsMap["?DUP"].code(); printD("?DUP >\t\t${this.vm.dataStack}");
		


		this.footer("/dictionary");
	}

	/// TODO: Tests a [VirtualMachine] instance.
	TestVirtualMachine(VirtualMachine t, String name) {
		this.header("VirtualMachine", t, name);
		this.separator();
		this.footer("/VirtualMachine");
	}
{'fraction_non_alphanumeric': 0.2671302924933524, 'fraction_numerical': 0.008590713847412558, 'mean_word_length': 3.8656716417910446, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 65, 'https://': 1, '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': '2942251', 'n_tokens_mistral': 2082, 'n_tokens_neox': 1887, 'n_words': 353}