Skip to content

Commit

Permalink
Merge pull request #32 from KQMATH/feat/testing
Browse files Browse the repository at this point in the history
Feat/testing
  • Loading branch information
andstor authored Apr 22, 2019
2 parents 82e5aa1 + 5bd907c commit e4726e5
Show file tree
Hide file tree
Showing 9 changed files with 5,242 additions and 1,498 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Node
node_modules
dist
lib
npm-debug.log
.env

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ TeX2Max supports Node and AMD, in addition to normal browser support.

## Main
```text
dist/
lib/
├── tex2max.amd.js (AMD)
├── tex2max.js (UMD)
└── tex2max.common.js (CommonJS, default)
Expand Down
8 changes: 8 additions & 0 deletions ava.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
require: [
"@babel/register"
],
babel: {
extensions: ['js']
}
};
6,354 changes: 4,880 additions & 1,474 deletions package-lock.json

Large diffs are not rendered by default.

27 changes: 17 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
"name": "tex2max",
"version": "1.0.4",
"description": "LaTeX math to Maxima code converter",
"main": "dist/tex2max.common.js",
"unpkg": "dist/tex2max.js",
"main": "lib/tex2max.common.js",
"unpkg": "lib/tex2max.js",
"scripts": {
"build": "parallel-webpack",
"watch": "parallel-webpack --watch",
"prepublish": "npm run build"
"build:watch": "parallel-webpack --watch",
"prepare": "npm run test && npm run build",
"test": "ava",
"test:watch": "ava --watch"
},
"repository": {
"type": "git",
Expand All @@ -28,17 +30,22 @@
"url": "https://github.com/KQMATH/tex2max/issues"
},
"files": [
"/dist",
"/lib",
"/src",
"LICENSE"
],
"homepage": "https://github.com/KQMATH/tex2max",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-preset-env": "^1.7.0",
"ava": "^1.4.1",
"@babel/cli": "^7.4.3",
"@babel/core": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"parallel-webpack": "^2.3.0",
"webpack": "^4.15.1",
"webpack-cli": "^3.0.8"
"webpack": "^4.30.0",
"webpack-cli": "^3.3.1"
},
"dependencies": {
"@babel/register": "^7.4.0",
"babel-loader": "^8.0.5"
}
}
47 changes: 47 additions & 0 deletions src/tests/integration.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @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();

test('Simple finite integral with numerical arguments',
[transpilation, singleVars],
'\\int_0^1xdx', 'integrate((x),x,(0),(1))');

test.failing('Simple finite integral with variable arguments',
transpilation,
'\\int_a^bxdx', 'integrate((x),x,(a),(b))');

test('Simple finite integral with variable arguments',
singleVars,
'\\int_a^bxdx', 'integrate((x),x,(a),(b))');

test('Simple finite integral with brackets around argument',
[transpilation, singleVars],
'\\int_0^1\\left(x\\right)dx', 'integrate(((x)),x,(0),(1))');
Loading

0 comments on commit e4726e5

Please sign in to comment.