Skip to content

Commit

Permalink
test: add test with closure in "functions" parser option
Browse files Browse the repository at this point in the history
Follows-up I9cbbd4b591b83f.

This verifies that the new Less_Parser::setOption code for $function
works even when it is not an array of strings in the
[0:class, 1:method] form.

Change-Id: Ia29c5d24dd68270d324b02f811b80afaba16c22d
  • Loading branch information
Krinkle committed Jan 18, 2024
1 parent fdfd346 commit c69c6da
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/phpunit/FixturesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ public function testOptionFunctions() {
CSS;
$this->assertSame( $expected, $css );

// test with closure
$parser = new Less_Parser( [
'functions' => [
'add' => static function ( $a, $b ) {
return new Less_Tree_Dimension( $a->value + $b->value );
}
]
] );
$parser->parse( $lessCode );
$css = trim( $parser->getCss() );
$this->assertSame( $expected, $css );

// test with directly with registerFunction()
$parser = new Less_Parser();
$parser->registerFunction( 'add', [ __CLASS__, 'fooBar2' ] );
Expand Down

0 comments on commit c69c6da

Please sign in to comment.