<commit_before><?php

namespace AmpProject\Validator\Spec\Section;

use AmpProject\Exception\InvalidSpecName;
use AmpProject\Tests\TestCase;
use AmpProject\Validator\Spec;

/**
 * Tests for AmpProject\Validator\Spec\Section\Tags.
 *
 * @covers  \AmpProject\Validator\Spec\Section\Tags
 * @package ampproject/amp-toolbox
 */
class TagsTest extends TestCase
{
    /** @var Tags */
    private $tags;

    public function __construct()
    {
        parent::__construct();
        $spec       = new Spec();
        $this->tags = $spec->tags();
    }

    public function testByTagName()
    {
        $tags = $this->tags->byTagName('STOP');

        $this->assertIsArray($tags);
        $this->assertCount(2, $tags);

        foreach ($tags as $tag) {
            $this->assertInstanceOf(Spec\Tag::class, $tag);
            $this->assertEquals('stop', $tag->tagName());
        }

        $this->assertEquals('lineargradient > stop', $tags[0]->specName());
        $this->assertEquals('radialgradient > stop', $tags[1]->specName());
    }

    public function testByTagNameReturnsEmptyArrayForUnknownTagName()
    {
        $tags = $this->tags->byTagName('utter nonsense');

        $this->assertIsArray($tags);
        $this->assertCount(0, $tags);
    }

    public function testBySpecName()
    {
        $tag = $this->tags->bySpecName('picture > source');

        $this->assertInstanceOf(Spec\Tag::class, $tag);
        $this->assertEquals('picture > source', $tag->specName());
        $this->assertEquals('source', $tag->tagName());
    }

    public function testBySpecNameThrowsExceptionForUnknownSpecName()
    {
        $this->expectException(InvalidSpecName::class);
        $this->tags->bySpecName('utter nonsense');
    }
}<commit_msg>Add tests for byFormat querying<commit_after><?php

namespace AmpProject\Validator\Spec\Section;

use AmpProject\Exception\InvalidFormat;
use AmpProject\Exception\InvalidSpecName;
use AmpProject\Format;
use AmpProject\Tests\TestCase;
use AmpProject\Validator\Spec;

/**
 * Tests for AmpProject\Validator\Spec\Section\Tags.
 *
 * @covers  \AmpProject\Validator\Spec\Section\Tags
 * @package ampproject/amp-toolbox
 */
class TagsTest extends TestCase
{
    /** @var Tags */
    private $tags;

    public function __construct()
    {
        parent::__construct();
        $spec       = new Spec();
        $this->tags = $spec->tags();
    }

    public function testByTagName()
    {
        $tags = $this->tags->byTagName('STOP');

        $this->assertIsArray($tags);
        $this->assertCount(2, $tags);

        foreach ($tags as $tag) {
            $this->assertInstanceOf(Spec\Tag::class, $tag);
            $this->assertEquals('stop', $tag->tagName());
        }

        $this->assertEquals('lineargradient > stop', $tags[0]->specName());
        $this->assertEquals('radialgradient > stop', $tags[1]->specName());
    }

    public function testByTagNameReturnsEmptyArrayForUnknownTagName()
    {
        $tags = $this->tags->byTagName('utter nonsense');

        $this->assertIsArray($tags);
        $this->assertCount(0, $tags);
    }

    public function testBySpecName()
    {
        $tag = $this->tags->bySpecName('picture > source');

        $this->assertInstanceOf(Spec\Tag::class, $tag);
        $this->assertEquals('picture > source', $tag->specName());
        $this->assertEquals('source', $tag->tagName());
    }

    public function testBySpecNameThrowsExceptionForUnknownSpecName()
    {
        $this->expectException(InvalidSpecName::class);
        $this->tags->bySpecName('utter nonsense');
    }

    public function testByFormat()
    {
        $tags = $this->tags->byFormat(Format::AMP);

        $this->assertIsArray($tags);
        $this->assertGreaterThan(1, $tags);

        foreach ($tags as $tag) {
            $this->assertInstanceOf(Spec\Tag::class, $tag);
            $this->assertContains(Format::AMP, $tag->htmlFormat());
        }
    }

    public function testByFormatThrowsExceptionForUnknownFormat()
    {
        $this->expectException(InvalidFormat::class);
        $this->tags->byFormat('utter nonsense');
    }
}
{'fraction_non_alphanumeric': 0.1583941605839416, 'fraction_numerical': 0.0021897810218978104, 'mean_word_length': 2.983527131782946, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 75, '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': '2638228', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1206, 'n_words': 196}