<commit_before><?php

use SkylarK\Purity5\DataStructures\PureTree as PureTree;

class PureTreeTest extends PHPUnit_Framework_TestCase
{
	// Tests

	public function test_SimpleTree() {
		
		$root = PureTree::buildRoot('<head><title>Welcome</title></head>');

		$this->assertEquals("html", $root->name());
		$this->assertEquals(0, count($root->attributes()));
		$this->assertEquals('<head><title>Welcome</title></head>', $root->contents());
		$this->assertEquals(0, count($root->children()));
		
		$c1 = $root->createChild("head", array(), '<title>Welcome</title>');
		$c2 = $c1->createChild("title", array(), 'Welcome');


		$this->assertEquals(1, count($root->children()));
		$this->assertEquals(1, count($c1->children()));
		$this->assertEquals(0, count($c2->children()));

		// Now test querying
		$result = $root->query("title");
		$this->assertEquals(1, count($result));
		$this->assertEquals($c2, $result[0]);
	}
}<commit_msg>Add a set of basic queries<commit_after><?php

use SkylarK\Purity5\DataStructures\PureTree as PureTree;

class PureTreeTest extends PHPUnit_Framework_TestCase
{
	// Tests

	public function test_SimpleTree() {
		
		$root = PureTree::buildRoot('<head><title>Welcome</title></head>');

		$this->assertEquals("html", $root->name());
		$this->assertEquals(0, count($root->attributes()));
		$this->assertEquals('<head><title>Welcome</title></head>', $root->contents());
		$this->assertEquals(0, count($root->children()));
		
		$c1 = $root->createChild("head", array(), '<title>Welcome</title>');
		$c2 = $c1->createChild("title", array(), 'Welcome');


		$this->assertEquals(1, count($root->children()));
		$this->assertEquals(1, count($c1->children()));
		$this->assertEquals(0, count($c2->children()));

		// Now test querying
		$result = $root->query("title");
		$this->assertEquals(1, count($result));
		$this->assertEquals($c2, $result[0]);

		// More complex query
		$result = $root->query("html > head > title");
		$this->assertEquals(1, count($result));
		$this->assertEquals($c2, $result[0]);

		// Another query
		$result = $root->query("html head title");
		//$this->assertEquals(1, count($result));
		//$this->assertEquals($c2, $result[0]);

		// Another query
		$result = $root->query("html title");
		//$this->assertEquals(1, count($result));
		//$this->assertEquals($c2, $result[0]);

		// Another query
		$result = $root->query("head > title");
		//$this->assertEquals(1, count($result));
		//$this->assertEquals($c2, $result[0]);
	}
}
{'fraction_non_alphanumeric': 0.23222940226171243, 'fraction_numerical': 0.01615508885298869, 'mean_word_length': 5.450520833333333, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 76, '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': '6642693', 'n_tokens_mistral': 870, 'n_tokens_neox': 790, 'n_words': 136}