| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\Math\Tests\WikiTexVC\Nodes; |
| 4 |
|
| 5 |
use ArgumentCountError; |
| 6 |
use MediaWiki\Extension\Math\WikiTexVC\Nodes\Fun2nb; |
| 7 |
use MediaWiki\Extension\Math\WikiTexVC\Nodes\Literal; |
| 8 |
use MediaWikiUnitTestCase; |
| 9 |
use TypeError; |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
class Fun2nbTest extends MediaWikiUnitTestCase { |
| 15 |
|
| 16 |
public function testEmptyFun2nb() { |
| 17 |
$this->expectException( ArgumentCountError::class ); |
| 18 |
new Fun2nb(); |
| 19 |
throw new ArgumentCountError( 'Should not create an empty fun2nb' ); |
| 20 |
} |
| 21 |
|
| 22 |
public function testOneArgumentFun2nb() { |
| 23 |
$this->expectException( ArgumentCountError::class ); |
| 24 |
new Fun2nb( '\\f' ); |
| 25 |
throw new ArgumentCountError( 'Should not create a fun2nb with one argument' ); |
| 26 |
} |
| 27 |
|
| 28 |
public function testIncorrectTypeFun2nb() { |
| 29 |
$this->expectException( TypeError::class ); |
| 30 |
new Fun2nb( '\\f', 'x', 'y' ); |
| 31 |
throw new TypeError( 'Should not create a fun2nb with incorrect type' ); |
| 32 |
} |
| 33 |
|
| 34 |
public function testBasicFunctionFun2nb() { |
| 35 |
$fq = new Fun2nb( '\\f', new Literal( 'a' ), new Literal( 'b' ) ); |
| 36 |
$this->assertEquals( '\\f {a}{b}', $fq->render(), 'Should create a basic function' ); |
| 37 |
} |
| 38 |
|
| 39 |
public function testCurliesFun2nb() { |
| 40 |
$f = new Fun2nb( '\\f', new Literal( 'a' ), new Literal( 'b' ) ); |
| 41 |
$this->assertEquals( '{\\f {a}{b}}', $f->inCurlies(), |
| 42 |
'Should create exactly one set of curlies' ); |
| 43 |
} |
| 44 |
} |