refactor: Cleanup git state - commit all staged changes
Major refactoring cleanup: - Add new controller architecture (class-controller-*.php) - Add new settings-v2 UI (views/settings-v2/) - Add new CSS architecture (agentic-sidebar.css, tokens) - Add esbuild build pipeline (scripts/build.js, package.json) - Add composer dependencies (vendor/) - Add frontend src directory (assets/js/src/index.jsx) - Add documentation files - Remove old/obsolete files (class-settings.php, old CSS) This commits all pending changes from previous refactoring efforts.
This commit is contained in:
47
vendor/parsica-php/parsica/tests/Internal/FP/CurryTest.php
vendored
Normal file
47
vendor/parsica-php/parsica/tests/Internal/FP/CurryTest.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of the Parsica library.
|
||||
*
|
||||
* Copyright (c) 2020 Mathias Verraes <mathias@verraes.net>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tests\Parsica\Parsica\Internal\FP;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use function Parsica\Parsica\Curry\curry;
|
||||
|
||||
final class CurryTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function curry()
|
||||
{
|
||||
$f = fn($a, $b, $c) => $a + $b + $c;
|
||||
$curried = curry($f);
|
||||
|
||||
$this->assertIsCallable($curried);
|
||||
$this->assertIsCallable($curried(1));
|
||||
$this->assertIsCallable($curried(1)(2));
|
||||
$this->assertIsCallable($curried(1)(2));
|
||||
|
||||
$this->assertEquals(6, $curried(1)(2)(3));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function partial_application()
|
||||
{
|
||||
$f = fn($a, $b, $c) => $a + $b + $c;
|
||||
|
||||
$this->assertIsCallable(curry($f, 1));
|
||||
$this->assertIsCallable(curry($f, 1, 2));
|
||||
|
||||
// I would expect this:
|
||||
// $this->assertEquals(6, curry($f, 1, 2, 3));
|
||||
|
||||
// But we must add a () at the end, which I feel is a bug:
|
||||
$this->assertIsCallable(curry($f, 1, 2, 3));
|
||||
$this->assertEquals(6, curry($f, 1, 2, 3)());
|
||||
}
|
||||
}
|
||||
59
vendor/parsica-php/parsica/tests/Internal/FP/FoldrTest.php
vendored
Normal file
59
vendor/parsica-php/parsica/tests/Internal/FP/FoldrTest.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of the Parsica library.
|
||||
*
|
||||
* Copyright (c) 2020 Mathias Verraes <mathias@verraes.net>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tests\Parsica\Parsica\Internal\FP;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use function Parsica\Parsica\Internal\FP\foldr;
|
||||
|
||||
final class FoldrTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function sum_implemented_as_foldr()
|
||||
{
|
||||
$actual = foldr([1, 2, 3], fn ($x, $y) => $x + $y, 0);
|
||||
$this->assertSame(6, $actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function associativity_is_correct()
|
||||
{
|
||||
$minus = fn($x, $y) => $x - $y;
|
||||
$input = [1, 2, 3, 4, 5];
|
||||
$init = 0;
|
||||
|
||||
// foldl: ((((0 - 1) - 2) - 3) - 4) - 5) = -15
|
||||
// foldr: (1 - (2 - (3 - (4 - (5 - 0))))) = 3
|
||||
|
||||
$actual = array_reduce($input, $minus, $init);
|
||||
$this->assertSame(-15, $actual);
|
||||
|
||||
$actual = foldr($input, $minus, $init);
|
||||
$this->assertSame(3, $actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function x()
|
||||
{
|
||||
$concat = fn($x, $y) => "$x$y";
|
||||
$input = [1, 2, 3, 4, 5];
|
||||
$init = "0";
|
||||
|
||||
// foldl: 012345
|
||||
// foldr: 123450
|
||||
|
||||
$actual = array_reduce($input, $concat, $init);
|
||||
$this->assertSame("012345", $actual);
|
||||
|
||||
$actual = foldr($input, $concat, $init);
|
||||
$this->assertSame("123450", $actual);
|
||||
}
|
||||
|
||||
}
|
||||
65
vendor/parsica-php/parsica/tests/Internal/PositionTest.php
vendored
Normal file
65
vendor/parsica-php/parsica/tests/Internal/PositionTest.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of the Parsica library.
|
||||
*
|
||||
* Copyright (c) 2020 Mathias Verraes <mathias@verraes.net>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tests\Parsica\Parsica\Internal;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Parsica\Parsica\Internal\Position;
|
||||
use Parsica\Parsica\StringStream;
|
||||
use function Parsica\Parsica\char;
|
||||
|
||||
final class PositionTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function update()
|
||||
{
|
||||
$position = Position::initial();
|
||||
$this->assertEquals(1, $position->line());
|
||||
$this->assertEquals(1, $position->column());
|
||||
$position = $position->advance("a");
|
||||
$this->assertEquals(1, $position->line());
|
||||
$this->assertEquals(2, $position->column());
|
||||
$position = $position->advance("\n");
|
||||
$this->assertEquals(2, $position->line());
|
||||
$this->assertEquals(1, $position->column());
|
||||
$position = $position->advance("\n\n\nabc");
|
||||
$this->assertEquals(5, $position->line());
|
||||
$this->assertEquals(4, $position->column());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function position_in_sequence()
|
||||
{
|
||||
$parser = char('a')->followedBy(char('b'));
|
||||
$input = new StringStream("abc", Position::initial());
|
||||
$result = $parser->run($input);
|
||||
|
||||
$expectedColumn = 3;
|
||||
$actualColumn = $result->remainder()->position()->column();
|
||||
$this->assertEquals($expectedColumn, $actualColumn);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function position_with_tabs()
|
||||
{
|
||||
$expected = 10;
|
||||
// All of these move the column position to 10
|
||||
$position = Position::initial()->advance("123456789");
|
||||
$this->assertEquals($expected, $position->column());
|
||||
$position = Position::initial()->advance("\t56789");
|
||||
$this->assertEquals($expected, $position->column());
|
||||
$position = Position::initial()->advance("\t\t9");
|
||||
$this->assertEquals($expected, $position->column());
|
||||
$position = Position::initial()->advance("1\t56789");
|
||||
$this->assertEquals($expected, $position->column());
|
||||
$position = Position::initial()->advance("123\t56789");
|
||||
$this->assertEquals($expected, $position->column());
|
||||
}
|
||||
}
|
||||
52
vendor/parsica-php/parsica/tests/Internal/StringStreamTest.php
vendored
Normal file
52
vendor/parsica-php/parsica/tests/Internal/StringStreamTest.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of the Parsica library.
|
||||
*
|
||||
* Copyright (c) 2020 Mathias Verraes <mathias@verraes.net>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tests\Parsica\Parsica\Internal;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Parsica\Parsica\Internal\Position;
|
||||
use Parsica\Parsica\StringStream;
|
||||
|
||||
final class StringStreamTest extends TestCase
|
||||
{
|
||||
|
||||
/** @test */
|
||||
public function take1()
|
||||
{
|
||||
$s = new StringStream("abc");
|
||||
$t = $s->take1();
|
||||
$this->assertEquals("a", $t->chunk());
|
||||
$expectedPosition = new Position("<input>", 1, 2);
|
||||
$expectedStream = new StringStream("bc", $expectedPosition);
|
||||
$this->assertEquals($expectedStream, $t->stream());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function takeN()
|
||||
{
|
||||
$s = new StringStream("abcde");
|
||||
$t = $s->takeN(3);
|
||||
$this->assertEquals("abc", $t->chunk());
|
||||
$expectedPosition = new Position("<input>", 1, 4);
|
||||
$expectedStream = new StringStream("de", $expectedPosition);
|
||||
$this->assertEquals($expectedStream, $t->stream());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function takeWhile()
|
||||
{
|
||||
$s = new StringStream("abc\nde");
|
||||
$t = $s->takeWhile(fn($c) => $c !== "\n");
|
||||
$this->assertEquals("abc", $t->chunk());
|
||||
$expectedPosition = new Position("<input>", 1, 4);
|
||||
$expectedStream = new StringStream("\nde", $expectedPosition);
|
||||
$this->assertEquals($expectedStream, $t->stream());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user