2023-02-28 13:20:52 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
2023-11-24 09:30:05 +00:00
|
|
|
|
namespace MediaWiki\Extension\Math\Tests\WikiTexVC\MMLmappings;
|
2023-02-28 13:20:52 +00:00
|
|
|
|
|
2023-11-24 09:30:05 +00:00
|
|
|
|
use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\Util\MMLParsingUtil;
|
2023-02-28 13:20:52 +00:00
|
|
|
|
use MediaWikiUnitTestCase;
|
|
|
|
|
|
|
|
|
|
/**
|
2023-11-24 09:30:05 +00:00
|
|
|
|
* @covers \MediaWiki\Extension\Math\WikiTexVC\MMLmappings\Util\MMLParsingUtil
|
2023-02-28 13:20:52 +00:00
|
|
|
|
*/
|
|
|
|
|
class MMLParsingUtilTest extends MediaWikiUnitTestCase {
|
|
|
|
|
|
|
|
|
|
public function testInvalidColor() {
|
|
|
|
|
$result = MMLParsingUtil::parseDefineColorExpression( "INVALID" );
|
|
|
|
|
$this->assertNull( $result );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testRGBOne() {
|
|
|
|
|
$result = MMLParsingUtil::parseDefineColorExpression(
|
|
|
|
|
"\\definecolor {ultramarine}{rgb}{0,0.12549019607843,0.37647058823529}" );
|
|
|
|
|
$this->assertEquals( 'ultramarine', $result['name'] );
|
|
|
|
|
$this->assertEquals( 'rgb', $result['type'] );
|
|
|
|
|
$this->assertEquals( '#002060', $result['hex'] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testInvalidColorString() {
|
|
|
|
|
$result = MMLParsingUtil::parseDefineColorExpression(
|
|
|
|
|
"\\definecolor {gray}{0.123}" );
|
|
|
|
|
$this->assertNull( $result );
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-29 10:30:51 +00:00
|
|
|
|
public function testUnicode_afr() {
|
|
|
|
|
$result = MMLParsingUtil::mapToFrakturUnicode( 'a' );
|
|
|
|
|
$this->assertEquals( '𝔞', $result );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testUnicode_bfr() {
|
|
|
|
|
$result = MMLParsingUtil::mapToFrakturUnicode( 'B' );
|
|
|
|
|
$this->assertEquals( '𝔅', $result );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testUnicode_Cfr() {
|
|
|
|
|
$result = MMLParsingUtil::mapToFrakturUnicode( 'C' );
|
|
|
|
|
$this->assertEquals( 'ℭ', $result );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testUnicodeUtf8Input() {
|
|
|
|
|
$result = MMLParsingUtil::mapToFrakturUnicode( '𝔄' );
|
|
|
|
|
$this->assertEquals( '𝔄', $result );
|
|
|
|
|
}
|
2023-02-28 13:20:52 +00:00
|
|
|
|
}
|