-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for string parameters and variables #56
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. I started the review by checking out your branch, building it (using nodejs 20), and ran the tests (npm run test). There are 13 tests failing.
Would you have a look into it, or maybe I did oversee something?
Thanks
spec/specs/stringBasicSpec.js
Outdated
beforeEach(function () { | ||
if (typeof require !== 'undefined') { | ||
Fparser = require('../../dist/fparser-dev'); | ||
} else { | ||
Fparser = window.Formula; | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CommonJS syntax is no longer needed / supported since the switch to a TypeScript library. Please remove this require "hack". (see for example spec/specs/basicSpec.js
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems not to be fixed - when executing the tests with npm run test
, the window
object is not present - please remove the whole beforeEach()
function, as it is no longer needed since the TypeScript build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am very sorry, but still, most of the tests fail when running npm run test
. Maybe I am missing something?
Please correct either the failing code, or fix the tests (one of the two seems not correct).
spec/specs/stringBasicSpec.js
Outdated
beforeEach(function () { | ||
if (typeof require !== 'undefined') { | ||
Fparser = require('../../dist/fparser-dev'); | ||
} else { | ||
Fparser = window.Formula; | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems not to be fixed - when executing the tests with npm run test
, the window
object is not present - please remove the whole beforeEach()
function, as it is no longer needed since the TypeScript build.
spec/specs/stringBasicSpec.js
Outdated
}); | ||
}); | ||
|
||
it('blocking math functions', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test fails.
}); | ||
}); | ||
|
||
it('blocking math operator "^"', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test fails.
spec/specs/stringBasicSpec.js
Outdated
expect(Fparser.calc('myFnFoo([myVar])', { myFnFoo: myFnFoo, myVar: 'bar' })).toEqual('foobar'); | ||
}); | ||
|
||
it('blocking math operator "*" of number and variable', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test fails.
spec/specs/stringBasicSpec.js
Outdated
}); | ||
|
||
it('correct in parentheses', function () { | ||
expect(Fparser.calc('(")")')).toEqual(')'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test fails.
expect(() => Fparser.calc('2x', { x: 'foo' })).toThrowError(expectedError); | ||
}); | ||
|
||
it('blocking math operator "+"', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test fails.
expect(Fparser.calc('" "')).toEqual(' '); | ||
}); | ||
|
||
it('allow special chars', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test fails.
}); | ||
}); | ||
|
||
it('blocking math operator "/"', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test fails.
}); | ||
}); | ||
|
||
it('blocking math operator "*"', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test fails.
expect(Fparser.calc('[myVar]', { myVar: 'foo' })).toEqual('foo'); | ||
}); | ||
|
||
it('support usage by custom function', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test fails.
Hi, @bylexus. First of all, thank you so much for promptly reviewing my pull request. I am sorry I completely missed the fact that the tests would all fail with the library refactoring in Typescript. I have now adjusted a few more details in the library and fixed all the tests accordingly. When I run |
Adding string support Merge branch 'barn2plugins-master' into develop
Hi @LuigiPulcini, Thanks for your contribution, this is a valuable addition. I did some adaptions to your original pull request, mostly type definitions and some documentation. For the time being, I merged it back to the
As soon as I added those additions, I will publish a new version. |
If there is any interest in adding support for string parameters and variables, this PR adjusts the version forked by @issidorov (https://github.com/issidorov/fparse/), updating it to the latest master branch (including the refactoring to Typescript).
This is also requested in #51.
An example of what this version can do is offered below:
I hope this helps.