<commit_before><?php

/*
 * This file is part of Psy Shell.
 *
 * (c) 2012-2020 <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Psy\Test\Exception;

use Psy\Exception\Exception;
use Psy\Exception\FatalErrorException;

class FatalErrorExceptionTest extends \Psy\Test\TestCase
{
    public function testInstance()
    {
        $e = new FatalErrorException();

        $this->assertInstanceOf(Exception::class, $e);
        $this->assertInstanceOf(\ErrorException::class, $e);
        $this->assertInstanceOf(FatalErrorException::class, $e);
    }

    public function testMessage()
    {
        $e = new FatalErrorException('{msg}', 0, 0, '{filename}', 13);

        $this->assertSame('{msg}', $e->getRawMessage());
        $this->assertStringContainsString('{msg}', $e->getMessage());
        $this->assertStringContainsString('{filename}', $e->getMessage());
        $this->assertStringContainsString('line 13', $e->getMessage());
    }

    public function testMessageWithNoFilename()
    {
        $e = new FatalErrorException('{msg}');

        $this->assertSame('{msg}', $e->getRawMessage());
        $this->assertStringContainsString('{msg}', $e->getMessage());
        $this->assertStringContainsString('eval()\'d code', $e->getMessage());
    }

    public function testNegativeOneLineNumberIgnored()
    {
        if (\defined('HHVM_VERSION')) {
            $this->markTestSkipped('HHVM does not support the line number argument, apparently.');
        }

        $e = new FatalErrorException('{msg}', 0, 1, null, -1);
        $this->assertEquals(0, $e->getLine());
    }
}
<commit_msg>Fix error line number change in PHP 8.0.<commit_after><?php

/*
 * This file is part of Psy Shell.
 *
 * (c) 2012-2020 <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Psy\Test\Exception;

use Psy\Exception\Exception;
use Psy\Exception\FatalErrorException;

class FatalErrorExceptionTest extends \Psy\Test\TestCase
{
    public function testInstance()
    {
        $e = new FatalErrorException();

        $this->assertInstanceOf(Exception::class, $e);
        $this->assertInstanceOf(\ErrorException::class, $e);
        $this->assertInstanceOf(FatalErrorException::class, $e);
    }

    public function testMessage()
    {
        $e = new FatalErrorException('{msg}', 0, 0, '{filename}', 13);

        $this->assertSame('{msg}', $e->getRawMessage());
        $this->assertStringContainsString('{msg}', $e->getMessage());
        $this->assertStringContainsString('{filename}', $e->getMessage());
        $this->assertStringContainsString('line 13', $e->getMessage());
    }

    public function testMessageWithNoFilename()
    {
        $e = new FatalErrorException('{msg}');

        $this->assertSame('{msg}', $e->getRawMessage());
        $this->assertStringContainsString('{msg}', $e->getMessage());
        $this->assertStringContainsString('eval()\'d code', $e->getMessage());
    }

    public function testNegativeOneLineNumberIgnored()
    {
        if (\defined('HHVM_VERSION')) {
            $this->markTestSkipped('HHVM does not support the line number argument, apparently.');
        }

        $e = new FatalErrorException('{msg}', 0, 1, null, -1);

        // In PHP 8.0+, the line number will be (as of the time of this change) 53, because it's
        // the line where the exception was first constructed. In older PHP versions, it'll be 0.
        $this->assertNotEquals(-1, $e->getLine());

        if (\version_compare(\PHP_VERSION, '8.0', '<')) {
            $this->assertEquals(0, $e->getLine());
        }
    }
}

{'fraction_non_alphanumeric': 0.15745930077395248, 'fraction_numerical': 0.012276487856952229, 'mean_word_length': 3.2590909090909093, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 47, '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': '4252956', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1093, 'n_words': 259}