Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7414477
Fun1Test.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
Fun1Test.php
View Options
<?php
namespace
MediaWiki\Extension\Math\Tests\WikiTexVC\Nodes
;
use
ArgumentCountError
;
use
MediaWiki\Extension\Math\WikiTexVC\Nodes\DQ
;
use
MediaWiki\Extension\Math\WikiTexVC\Nodes\FQ
;
use
MediaWiki\Extension\Math\WikiTexVC\Nodes\Fun1
;
use
MediaWiki\Extension\Math\WikiTexVC\Nodes\Literal
;
use
MediaWiki\Extension\Math\WikiTexVC\Nodes\TexArray
;
use
MediaWikiUnitTestCase
;
use
RuntimeException
;
use
TypeError
;
/**
* @covers \MediaWiki\Extension\Math\WikiTexVC\Nodes\Fun1
*/
class
Fun1Test
extends
MediaWikiUnitTestCase
{
public
function
testEmptyFun1
()
{
$this
->
expectException
(
ArgumentCountError
::
class
);
new
Fun1
();
throw
new
ArgumentCountError
(
'Should not create an empty fun1'
);
}
public
function
testOneArgumentFun1
()
{
$this
->
expectException
(
ArgumentCountError
::
class
);
new
Fun1
(
'
\\
f'
);
throw
new
ArgumentCountError
(
'Should not create a fun1 with one argument'
);
}
public
function
testIncorrectTypeFun1
()
{
$this
->
expectException
(
TypeError
::
class
);
new
Fun1
(
'
\\
f'
,
'x'
);
throw
new
RuntimeException
(
'Should not create a fun1 with incorrect type'
);
}
public
function
testBasicFunctionFun1
()
{
$f
=
new
Fun1
(
'
\\
f'
,
new
Literal
(
'a'
)
);
$this
->
assertEquals
(
'{
\\
f {a}}'
,
$f
->
render
(),
'Should create a basic function'
);
}
public
function
testCurliesFun1
()
{
$f
=
new
Fun1
(
'
\\
f'
,
new
Literal
(
'a'
)
);
$this
->
assertEquals
(
'{
\\
f {a}}'
,
$f
->
inCurlies
(),
'Should create exactly one set of curlies'
);
}
public
function
testExtractIdentifiersFun1
()
{
$f
=
new
Fun1
(
'
\\
mathbf'
,
new
Literal
(
'B'
)
);
$this
->
assertEquals
(
[
'
\\
mathbf{B}'
],
$f
->
extractIdentifiers
(),
'Should extract identifiers'
);
}
public
function
testExtractExtendedLiteralsFun1
()
{
$f
=
new
Fun1
(
'
\\
mathbf'
,
new
Literal
(
'
\\
infty'
)
);
$this
->
assertEquals
(
[],
$f
->
extractIdentifiers
(),
'Should not extract extended literals as identifiers.'
);
}
public
function
testGetters
()
{
$f
=
new
Fun1
(
'
\\
mathbf'
,
new
Literal
(
'
\\
infty'
)
);
$this
->
assertNotEmpty
(
$f
->
getFname
()
);
$this
->
assertNotEmpty
(
$f
->
getArg
()
);
}
public
function
testExtractPhantomIdentifiers
()
{
$f
=
new
Fun1
(
'
\\
hphantom'
,
new
Literal
(
'A'
)
);
$this
->
assertEquals
(
[],
$f
->
extractIdentifiers
(),
'Should not extract phantom identifiers.'
);
}
public
function
testIgnoreUnknownFunctions
()
{
$f
=
new
Fun1
(
'
\\
unknown'
,
new
Literal
(
'A'
)
);
$this
->
assertEquals
(
[
'A'
],
$f
->
extractIdentifiers
(),
'Should ignore unknown functions.'
);
}
public
function
testExtractIdentifierMods
()
{
$f
=
new
Fun1
(
'
\\
mathbf'
,
new
Literal
(
'B'
)
);
$this
->
assertEquals
(
[
'
\\
mathbf{B}'
],
$f
->
getModIdent
(),
'Should extract identifier modifications.'
);
}
public
function
testExtractSubscripts
()
{
$f
=
new
Fun1
(
'
\\
mathbf'
,
new
Literal
(
'B'
)
);
$this
->
assertEquals
(
[
'
\\
mathbf{B}'
],
$f
->
extractSubscripts
(),
'Should extract subscripts.'
);
}
public
function
testExtractSubscriptsExtendedLits
()
{
$f
=
new
Fun1
(
'
\\
mathbf'
,
new
Literal
(
'
\\
infty'
)
);
$this
->
assertEquals
(
[
'
\\
mathbf{
\\
infty}'
],
$f
->
extractSubscripts
(),
'Should extract subscripts for extended literals.'
);
}
public
function
testExtractSubscriptsEmptyMods
()
{
$f
=
new
Fun1
(
'
\\
mathbf'
,
new
Literal
(
''
)
);
$this
->
assertEquals
(
[],
$f
->
extractSubscripts
(),
'Should not extract subscripts for empty mods.'
);
}
public
function
testMathRmLiteral
()
{
$f
=
new
Fun1
(
'
\\
mathrm'
,
new
Literal
(
'b'
)
);
$this
->
assertStringContainsString
(
'mathvariant="normal"'
,
$f
->
renderMML
()
);
}
public
function
testMathRmCurly
()
{
$f
=
new
Fun1
(
'
\\
mathrm'
,
TexArray
::
newCurly
(
new
Literal
(
'a'
),
new
Literal
(
'b'
),
)
);
$rendering
=
$f
->
renderMML
();
preg_match_all
(
'/mathvariant="normal"/'
,
$rendering
,
$matches
);
$this
->
assertCount
(
2
,
$matches
[
0
]
);
}
public
function
testMathRmDq
()
{
$f
=
new
Fun1
(
'
\\
mathrm'
,
TexArray
::
newCurly
(
new
DQ
(
new
Literal
(
'a'
),
new
Literal
(
'b'
)
)
)
);
$rendering
=
$f
->
renderMML
();
preg_match_all
(
'/mathvariant="normal"/'
,
$rendering
,
$matches
);
$this
->
assertCount
(
2
,
$matches
[
0
]
);
}
public
function
testMathRmFq
()
{
$f
=
new
Fun1
(
'
\\
mathrm'
,
TexArray
::
newCurly
(
new
FQ
(
new
Literal
(
'a'
),
new
Literal
(
'b'
),
new
Literal
(
'c'
)
)
)
);
$rendering
=
$f
->
renderMML
();
preg_match_all
(
'/mathvariant="normal"/'
,
$rendering
,
$matches
);
$this
->
assertCount
(
2
,
$matches
[
0
]
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 22, 01:35 (1 d, 15 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a8/bb/6817a69998e9d98293780b8bb370
Default Alt Text
Fun1Test.php (4 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment