-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from KQMATH/develop
v1.3.0
- Loading branch information
Showing
6 changed files
with
171 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* @author André Storhaug <[email protected]> | ||
* @copyright 2019 NTNU | ||
*/ | ||
|
||
import test from 'ava'; | ||
import TeX2Max from '../index'; | ||
|
||
test.beforeEach(t => { | ||
t.context.TeX2Max = new TeX2Max(); | ||
}); | ||
|
||
function transpilation(t, input, expected) { | ||
let maximaCode = t.context.TeX2Max.toMaxima(input); | ||
t.is(maximaCode, expected); | ||
} | ||
transpilation.title = ( | ||
providedTitle = '', input, expected) => `${providedTitle} ${input}`.trim(); | ||
|
||
function singleVars(t, input, expected) { | ||
t.context.TeX2Max.updateOptions({ | ||
onlySingleVariables: true, | ||
addTimesSign: true, | ||
}); | ||
transpilation(t, input, expected); | ||
} | ||
singleVars.title = ( | ||
providedTitle = '', input, | ||
expected) => `SingleVars: ${providedTitle} ${input}`.trim(); | ||
|
||
function transpilationError(t, input) { | ||
t.throws(() => { | ||
let maximaCode = t.context.TeX2Max.toMaxima(input); | ||
}, Error); | ||
} | ||
transpilationError.title = ( | ||
providedTitle = '', input) => `${providedTitle} ${input}`.trim(); | ||
|
||
|
||
// Point type "." decimal numbers | ||
test('Short point type decimal number with leading zero', | ||
[transpilation, singleVars], | ||
'0.2', '0.2'); | ||
|
||
test('Long point type decimal number with leading zero', | ||
[transpilation, singleVars], | ||
'1234.1234', '1234.1234'); | ||
|
||
test('Short point type decimal number with leading zero in simple function', | ||
[transpilation, singleVars], | ||
'\\sin(0.2)', 'sin(0.2)'); | ||
|
||
test('Long point type decimal number with leading zero in simple function', | ||
[transpilation, singleVars], | ||
'\\sin(1234.1234)', 'sin(1234.1234)'); | ||
|
||
test('point type decimal number with leading decimal separator that should throw an error', | ||
[transpilationError], | ||
'.2'); | ||
|
||
test('Point type decimal number with trailing decimal separator that should throw an error', | ||
[transpilationError], | ||
'.2'); | ||
|
||
test('Point type decimal number with more than one decimal separator that should throw an error', | ||
[transpilationError], | ||
'1.2.3'); | ||
|
||
test('Point type decimal number with trailing decimal separator in simple function that should throw an error', | ||
[transpilationError], | ||
'\\sin(.2)'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters