File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
test/unit-tests/type/fraction/function Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,7 @@ export const latexFunctions = {
124124 expm1 : `\\left(e${ latexOperators . pow } {\${args[0]}}-1\\right)` ,
125125 fix : { 1 : '\\mathrm{${name}}\\left(${args[0]}\\right)' } ,
126126 floor : { 1 : '\\left\\lfloor${args[0]}\\right\\rfloor' } ,
127+ fraction : { 2 : '\\frac{${args[0]}}{${args[1]}}' } ,
127128 gcd : '\\gcd\\left(${args}\\right)' ,
128129 hypot : '\\hypot\\left(${args}\\right)' ,
129130 log : {
Original file line number Diff line number Diff line change 11import assert from 'assert'
2- import math from '../../../../../src/defaultInstance.js'
32import Fraction from 'fraction.js'
3+ import math from '../../../../../src/defaultInstance.js'
44
55describe ( 'fraction' , function ( ) {
66 it ( 'should create a fraction' , function ( ) {
@@ -81,6 +81,13 @@ describe('fraction', function () {
8181 assert . throws ( function ( ) { math . fraction ( - Infinity ) } , / E r r o r : - I n f i n i t y c a n n o t b e r e p r e s e n t e d a s a f r a c t i o n / )
8282 assert . throws ( function ( ) { math . fraction ( NaN ) } , / E r r o r : N a N c a n n o t b e r e p r e s e n t e d a s a f r a c t i o n / )
8383 } )
84+
85+ it ( 'should show a Latex Fraction as one over another' , function ( ) {
86+ const node1 = math . parse ( 'fraction(1,2)' )
87+ assert . strictEqual ( node1 . toTex ( ) , '\\frac{1}{2}' )
88+ const node2 = math . parse ( 'fraction(a,b)' )
89+ assert . strictEqual ( node2 . toTex ( ) , '\\frac{ a}{\\mathrm{b}}' )
90+ } )
8491} )
8592
8693function equalFraction ( a , b ) {
You can’t perform that action at this time.
0 commit comments