pieterderycke / Jace

Jace.NET is a calculation engine for the .NET platform.
MIT License
436 stars 94 forks source link

Issue with variable case sensitivity #1

Closed jjneuhart closed 10 years ago

jjneuhart commented 10 years ago

When testing out your example:

CalculationEngine engine = new CalculationEngine(); Func<Dictionary<string, double>, double> formula = engine.Build("var1+2/(3*otherVariable)");

        Dictionary<string, double> variables = new Dictionary<string, double>();
        variables.Add("var1", 2);
        variables.Add("otherVariable", 4.2);

        double result = formula(variables);

I get an exception that says "othervariable is not defined." If I change 'variables.Add("otherVariable",4.2");' to 'variables.Add("othervariable",4.2");' then it works fine. The variables in the formula seem to be getting converted to lower case. Can you confirm this bug? I am using version 0.8.3.

pieterderycke commented 10 years ago

This seems to be bug related to casing. I have already done the analysis and it is only occurring when you construct a Func accepting a dictionary. When the calculate is called directly on the CalculationEngine object, the bug is not occurring.

CalculationEngine engine = new CalculationEngine();

Dictionary<string, double> variables = new Dictionary<string, double>();
variables.Add("var1", 2);
variables.Add("otherVariable", 4.2);

double result = engine.Calculate("var1+2/(3*otherVariable)", variables);

I will do the necessary modifications to fix the bug and release it as part of version 0.8.4. Currently, all variables in Jace should be case insensitive. Should I also add an option to make them case sensitive? Or are case insensitive variables sufficient for you?

jjneuhart commented 10 years ago

Pieter,

I don't really see a need for case sensitivity, at least on the project that I am working on. Thanks for fixing the bug, and thanks for all of your great work.

Jordan Neuhart

On Mon, Dec 9, 2013 at 12:05 AM, Pieter De Rycke notifications@github.comwrote:

This seems to be bug related to casing. I have already done the analysis and it is only occurring when you construct a Func accepting a dictionary. When the calculate is called directly on the CalculationEngine object, the bug is not occurring.

CalculationEngine engine = new CalculationEngine(); Dictionary<string, double> variables = new Dictionary<string, double>();variables.Add("var1", 2);variables.Add("otherVariable", 4.2); double result = engine.Calculate("var1+2/(3*otherVariable)", variables);

I will do the necessary modifications to fix the bug and release it as part of version 0.8.4. Currently, all variables in Jace should be case insensitive. Should I also add an option to make them case sensitive? Or are case insensitive variables sufficient for you?

— Reply to this email directly or view it on GitHubhttps://github.com/pieterderycke/Jace/issues/1#issuecomment-30107471 .

email: jjneuhart@gmail.com cell: 402-217-1377

pieterderycke commented 10 years ago

Jordan,

Jace 0.8.4 has been released. It fixes your bug.

Kind regards, Pieter

Date: Mon, 9 Dec 2013 06:57:56 -0800 From: notifications@github.com To: Jace@noreply.github.com CC: pieter_de_rycke@hotmail.com Subject: Re: [Jace] Issue with variable case sensitivity (#1)

Pieter,

I don't really see a need for case sensitivity, at least on the project

that I am working on. Thanks for fixing the bug, and thanks for all of

your great work.

Jordan Neuhart

On Mon, Dec 9, 2013 at 12:05 AM, Pieter De Rycke

notifications@github.comwrote:

This seems to be bug related to casing. I have already done the analysis

and it is only occurring when you construct a Func accepting a dictionary.

When the calculate is called directly on the CalculationEngine object, the

bug is not occurring.

CalculationEngine engine = new CalculationEngine();

Dictionary<string, double> variables = new Dictionary<string, double>();variables.Add("var1", 2);variables.Add("otherVariable", 4.2);

double result = engine.Calculate("var1+2/(3*otherVariable)", variables);

I will do the necessary modifications to fix the bug and release it as

part of version 0.8.4. Currently, all variables in Jace should be case

insensitive. Should I also add an option to make them case sensitive? Or

are case insensitive variables sufficient for you?

Reply to this email directly or view it on GitHubhttps://github.com/pieterderycke/Jace/issues/1#issuecomment-30107471

.

email: jjneuhart@gmail.com

cell: 402-217-1377

— Reply to this email directly or view it on GitHub.