Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Create npm package

  • Loading branch information...
commit 797024f026ee273d13ebabccafeb71aecd614f83 1 parent a74b9e3
@adamschmideg adamschmideg authored committed
View
1  .gitignore
@@ -0,0 +1 @@
+node_modules
View
6 Cakefile
@@ -5,7 +5,7 @@ fs = require 'fs'
querystring = require 'querystring'
#Globals
-COMPILER_PATH = '/usr/share/java/compiler.jar'
+COMPILER_PATH = './node_modules/closure-compiler/lib/vendor/compiler.jar'
VERSION = '0.9.4'
YEAR = (new Date).getFullYear
LICENSE = fs.readFileSync './license.include', 'utf8'
@@ -23,7 +23,7 @@ task 'build', 'Building', ->
exec "sed -i -e '1r ./license.include' -e '1{h; D;}' -e '2{p}' ./excelFormulaUtilities-#{VERSION}.min.js", (err, stdout, stderr) ->
throw err if err
console.log stdout + stderr
- exec 'docco ./src/*.js', (err, stdout, stderr) ->
+ exec 'node_modules/.bin/docco ./src/*.js', (err, stdout, stderr) ->
throw err if err
console.log stdout + stderr
exec "cat ./src/core.js ./src/ExcelFormulaUtilities.js > ./excelFormulaUtilities-#{VERSION}.js" , (err, stdout, stderr) ->
@@ -94,4 +94,4 @@ task 'cloudBuild', 'Building in the cloud.', ->
req.write query
req.end
- #TODO Get docco working with cloud9.
+ #TODO Get docco working with cloud9.
View
30 package.json
@@ -0,0 +1,30 @@
+{
+ "author": "Josh Bennett (http://joshbennett.me/)",
+ "name": "excel-formula",
+ "description": "Methods to beautify an excel formula and convert it to JavaScript or C#",
+ "version": "0.9.4",
+ "homepage": "http://excelformulabeautifier.com/",
+ "contributors": [
+ {"name": "Adam Schmideg", "url": "http://adam.schmideg.net"}
+ ],
+ "repository": {
+ "url": "git://github.com/joshatjben/excelFormulaUtilitiesJS.git"
+ },
+ "keyword": ["excel", "formula", "convert"],
+ "scripts": {
+ "test": "qunit -t ./test/ExcelFormulaUtilities.test.js -d ./src/core.js -c ./src/ExcelFormulaUtilities.js"
+ },
+ "main": "./src/main",
+ "dependencies": {},
+ "devDependencies": {
+ "qunit": "0.5.x",
+ "coffee-script": "~1.1.3",
+ "docco": "~0.4.0",
+ "closure-compiler": "0.1.2"
+ },
+ "optionalDependencies": {},
+ "engines": {
+ "node": "*"
+ },
+ "license": "MIT"
+}
View
10 src/ExcelFormulaUtilities.js
@@ -13,6 +13,10 @@
*
* Based on Ewbi's Go Calc Prototype Excel Formula Parser. [http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html]
*/ (function () {
+ if (typeof window === 'undefined') {
+ window = root;
+ }
+
var excelFormulaUtilities = window.excelFormulaUtilities = window.excelFormulaUtilities || {},
core = window.excelFormulaUtilities.core,
formatStr = window.excelFormulaUtilities.string.formatStr,
@@ -771,10 +775,7 @@
default:
break;
-
}
-
-
return tokenString;
};
@@ -1049,6 +1050,7 @@
// If in the sum function break aout cell names and add
case "sum":
outstr = breakOutRanges(tokenString, "+");
+
debugger;
//TODO loop through and add ranges together
break;
@@ -1111,4 +1113,6 @@
var formula2JavaScript = excelFormulaUtilities.formula2JavaScript = function (formula) {
return formula2CSharp(formula).replace('==', '===');
}
+
+ excelFormulaUtilities.getTokens = getTokens;
}());
View
4 src/core.js
@@ -16,7 +16,9 @@
(function () {
-
+ if (typeof window === 'undefined') {
+ window = root;
+ }
var excelFormulaUtilities = window.excelFormulaUtilities = window.excelFormulaUtilities || {};
var core = window.excelFormulaUtilities.core = {};
window.excelFormulaUtilities.string = window.excelFormulaUtilities.string || {};
View
7 src/main.coffee
@@ -0,0 +1,7 @@
+
+require './core'
+require './ExcelFormulaUtilities'
+xl = excelFormulaUtilities
+module.exports =
+ getTokens: (f) -> xl.getTokens(f).items
+ toJavaScript: (f) -> xl.formula2JavaScript(f)
View
20 src/main.js
@@ -0,0 +1,20 @@
+// Generated by CoffeeScript 1.3.3
+(function() {
+ var xl;
+
+ require('./core');
+
+ require('./ExcelFormulaUtilities');
+
+ xl = excelFormulaUtilities;
+
+ module.exports = {
+ getTokens: function(f) {
+ return xl.getTokens(f).items;
+ },
+ toJavaScript: function(f) {
+ return xl.formula2JavaScript(f);
+ }
+ };
+
+}).call(this);
View
38 test/ExcelFormulaUtilities.test.js
@@ -1,23 +1,23 @@
-module("parser");
+QUnit.module("parser");
/*
test("Test formatFormula ()", function() {
var inputFormula = "IF('foo' = 'foo', 'foo', 'bar')";
var formattedFormula = 'IF(\n\t"foo" = "foo",\n\t"foo",\n\t"bar"\n)';
console.log(formattedFormula);
console.log(excelFormulaUtilities.formatFormula(inputFormula))
- //equals(excelFormulaUtilities.formatFormula(inputFormula), "Simple formating example.");
- equals(typeof {}, "object", "foo exsits");
+ //equal(excelFormulaUtilities.formatFormula(inputFormula), "Simple formating example.");
+ equal(typeof {}, "object", "foo exsits");
});*/
test("formatFormula", function() {
var inputFormula = 'IF("foo" = "foo", "foo", "bar")';
var excpected = 'IF\n(\n\t"foo"= "foo",\n\t"foo",\n\t"bar"\n)';
- equals(window.excelFormulaUtilities.formatFormula(inputFormula), excpected, "Simple formating example.");
+ equal(window.excelFormulaUtilities.formatFormula(inputFormula), excpected, "Simple formating example.");
inputFormula = 'IF(R[39]C[11]>65,R[25]C[42],ROUND((R[11]C[11]*IF(OR(AND(R[39]C[11]>=55, R[40]C[11]>=20),AND(R[40]C[11]>=20,R11C3="YES")),R[44]C[11],R[43]C[11]))+(R[14]C[11] *IF(OR(AND(R[39]C[11]>=55,R[40]C[11]>=20),AND(R[40]C[11]>=20,R11C3="YES")), R[45]C[11],R[43]C[11])),0))'
excpected = 'IF\n(\n\tR[39]C[11]> 65,\n\tR[25]C[42],\n\tROUND\n\t(\n\t\t( R[11]C[11]*\n\t\t\tIF\n\t\t\t(\n\t\t\t\tOR\n\t\t\t\t(\n\t\t\t\t\tAND\n\t\t\t\t\t(\n\t\t\t\t\t\tR[39]C[11]>= 55,\n\t\t\t\t\t\tR[40]C[11]>= 20\n\t\t\t\t\t),\n\t\t\t\t\tAND\n\t\t\t\t\t(\n\t\t\t\t\t\tR[40]C[11]>= 20,\n\t\t\t\t\t\tR11C3= "YES"\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\tR[44]C[11],\n\t\t\t\tR[43]C[11]\n\t\t\t) )+ ( R[14]C[11]*\n\t\t\tIF\n\t\t\t(\n\t\t\t\tOR\n\t\t\t\t(\n\t\t\t\t\tAND\n\t\t\t\t\t(\n\t\t\t\t\t\tR[39]C[11]>= 55,\n\t\t\t\t\t\tR[40]C[11]>= 20\n\t\t\t\t\t),\n\t\t\t\t\tAND\n\t\t\t\t\t(\n\t\t\t\t\t\tR[40]C[11]>= 20,\n\t\t\t\t\t\tR11C3= "YES"\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\tR[45]C[11],\n\t\t\t\tR[43]C[11]\n\t\t\t) ),\n\t\t0\n\t)\n)';
- equals(excelFormulaUtilities.formatFormula(inputFormula), excpected, "advanced example.");
+ equal(excelFormulaUtilities.formatFormula(inputFormula), excpected, "advanced example.");
});
@@ -25,56 +25,56 @@ test("formatFormulaHTML", function() {
var inputFormula = 'IF("foo" = "foo", "foo", "bar")';
var excpected = '<span class="function">IF</span><br /><span class="function_start">(</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="quote_mark">"</span><span class="text">foo</span><span class="quote_mark">"</span> =&nbsp;<span class="quote_mark">"</span><span class="text">foo</span><span class="quote_mark">"</span>,<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="quote_mark">"</span><span class="text">foo</span><span class="quote_mark">"</span>,<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="quote_mark">"</span><span class="text">bar</span><span class="quote_mark">"</span><br /><span class="function_stop">)</span>';
- equals(window.excelFormulaUtilities.formatFormulaHTML(inputFormula), excpected, "Simple formating example.");
+ equal(window.excelFormulaUtilities.formatFormulaHTML(inputFormula), excpected, "Simple formating example.");
inputFormula = 'IF(R[39]C[11]>65,R[25]C[42],ROUND((R[11]C[11]*IF(OR(AND(R[39]C[11]>=55, R[40]C[11]>=20),AND(R[40]C[11]>=20,R11C3="YES")),R[44]C[11],R[43]C[11]))+(R[14]C[11] *IF(OR(AND(R[39]C[11]>=55,R[40]C[11]>=20),AND(R[40]C[11]>=20,R11C3="YES")), R[45]C[11],R[43]C[11])),0))'
excpected = '<span class="function">IF</span><br /><span class="function_start">(</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>R[39]C[11] >&nbsp;65,<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>R[25]C[42],<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function">ROUND</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_start">(</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>(&nbsp;R[11]C[11] *<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function">IF</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_start">(</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function">OR</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_start">(</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function">AND</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_start">(</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>R[39]C[11] >=&nbsp;55,<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>R[40]C[11] >=&nbsp;20<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_stop">)</span>,<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function">AND</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_start">(</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>R[40]C[11] >=&nbsp;20,<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>R11C3 =&nbsp;<span class="quote_mark">"</span><span class="text">YES</span><span class="quote_mark">"</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_stop">)</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_stop">)</span>,<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>R[44]C[11],<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>R[43]C[11]<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_stop">)</span> ) +&nbsp;(&nbsp;R[14]C[11] *<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function">IF</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_start">(</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function">OR</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_start">(</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function">AND</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_start">(</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>R[39]C[11] >=&nbsp;55,<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>R[40]C[11] >=&nbsp;20<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_stop">)</span>,<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function">AND</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_start">(</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>R[40]C[11] >=&nbsp;20,<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>R11C3 =&nbsp;<span class="quote_mark">"</span><span class="text">YES</span><span class="quote_mark">"</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_stop">)</span><br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_stop">)</span>,<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>R[45]C[11],<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>R[43]C[11]<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_stop">)</span> ),<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>0<br /><span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="function_stop">)</span><br /><span class="function_stop">)</span>';
- equals(excelFormulaUtilities.formatFormulaHTML(inputFormula), excpected, "advanced example.");
+ equal(excelFormulaUtilities.formatFormulaHTML(inputFormula), excpected, "advanced example.");
});
-module("convert");
+QUnit.module("convert");
test("formula2CSharp", function() {
var inputFormula = 'IF("foo" = "foo", "foo", "bar")',
excpected = '("foo"=="foo"?"foo":"bar")';
- equals(excelFormulaUtilities.formula2CSharp(inputFormula), excpected, "Simple if example.");
+ equal(excelFormulaUtilities.formula2CSharp(inputFormula), excpected, "Simple if example.");
inputFormula = 'IF(IF(true, "foo", "bar") = "foo", "foo", "bar")';
excpected = '((true?"foo":"bar")=="foo"?"foo":"bar")';
- equals(excelFormulaUtilities.formula2CSharp(inputFormula), excpected, "Nested If Test.");
+ equal(excelFormulaUtilities.formula2CSharp(inputFormula), excpected, "Nested If Test.");
inputFormula = 'IF(IF(MAX(1, -10)>0, "foo", "bar") = "foo", "foo", "bar")';
excpected = '((Math.Max(1,-10)>0?"foo":"bar")=="foo"?"foo":"bar")';
- equals(excelFormulaUtilities.formula2CSharp(inputFormula), excpected, "Nested If Test with a nested function.");
+ equal(excelFormulaUtilities.formula2CSharp(inputFormula), excpected, "Nested If Test with a nested function.");
inputFormula = 'SUM(1,1)';
excpected = '(1+1)';
- equals(excelFormulaUtilities.formula2CSharp(inputFormula), excpected, "SUM(1,1)");
+ equal(excelFormulaUtilities.formula2CSharp(inputFormula), excpected, "SUM(1,1)");
inputFormula = 'SUM(1,1,1,1)';
excpected = '(1+1+1+1)';
- equals(excelFormulaUtilities.formula2CSharp(inputFormula), excpected, "SUM(1,1,1,1)");
+ equal(excelFormulaUtilities.formula2CSharp(inputFormula), excpected, "SUM(1,1,1,1)");
inputFormula = 'IF(FOO_BAR = "foo bar", "THIS WORKED", "THIS ISN\'T WORKING")';
excpected = '(FOO_BAR=="foo bar"?"THIS WORKED":"THIS ISN\'T WORKING")';
- equals(excelFormulaUtilities.formula2JavaScript(inputFormula), excpected, "Test that strings keep correct spaces. See issue #2. https://github.com/joshatjben/excelFormulaUtilitiesJS/issues/2");
+ equal(excelFormulaUtilities.formula2JavaScript(inputFormula), excpected, "Test that strings keep correct spaces. See issue #2. https://github.com/joshatjben/excelFormulaUtilitiesJS/issues/2");
});
test("formula2JavaScript", function() {
var inputFormula = 'IF("foo" = "foo", "foo", "bar")',
excpected = '("foo"=="foo"?"foo":"bar")';
- equals(excelFormulaUtilities.formula2JavaScript(inputFormula), excpected, "Simple if example.");
+ equal(excelFormulaUtilities.formula2JavaScript(inputFormula), excpected, "Simple if example.");
inputFormula = 'IF(IF(true, "foo", "bar") = "foo", "foo", "bar")';
excpected = '((true?"foo":"bar")=="foo"?"foo":"bar")';
- equals(excelFormulaUtilities.formula2JavaScript(inputFormula), excpected, "Nested If Test.");
+ equal(excelFormulaUtilities.formula2JavaScript(inputFormula), excpected, "Nested If Test.");
inputFormula = 'IF(IF(MAX(1, -10)>0, "foo", "bar") = "foo", "foo", "bar")';
excpected = '((Math.Max(1,-10)>0?"foo":"bar")=="foo"?"foo":"bar")';
- equals(excelFormulaUtilities.formula2JavaScript(inputFormula), excpected, "Nested If Test with a nested function.");
+ equal(excelFormulaUtilities.formula2JavaScript(inputFormula), excpected, "Nested If Test with a nested function.");
inputFormula = 'IF(FOO_BAR = "foo bar", "THIS WORKED", "THIS ISN\'T WORKING")';
excpected = '(FOO_BAR=="foo bar"?"THIS WORKED":"THIS ISN\'T WORKING")';
- equals(excelFormulaUtilities.formula2JavaScript(inputFormula), excpected, "Test that strings keep correct spaces. See issue #2. https://github.com/joshatjben/excelFormulaUtilitiesJS/issues/2");
-});
+ equal(excelFormulaUtilities.formula2JavaScript(inputFormula), excpected, "Test that strings keep correct spaces. See issue #2. https://github.com/joshatjben/excelFormulaUtilitiesJS/issues/2");
+});
Please sign in to comment.
Something went wrong with that request. Please try again.