[SOLVED] BUG - Math constants in javascript engine


#1

Cloned 10 minutes ago to be sure. Just a small niggle. With JUCE, this gtest fails as the var is zero . . 

JavascriptEngine eng;
EXPECT_NEAR(M_PI, static_cast<double>(eng.evaluate("Math.PI", &res)), 0.001);


... and no error is given in the result object.

However, with parentheses the test passes . .

EXPECT_NEAR(M_PI, static_cast<double>(eng.evaluate("Math.PI()", &res)), 0.001); // all good

This is worrying, because in the node interpreter, adding parenteses gives the error "TypeError: number is not a function", i.e. it only works without parentheses, so I cant have scripts that work in both. I'm geussing from the observed behaviour (lack of error in Result object) that Math.PI is considered a function in the JUCE interpreter, rather than a numeric constant, but I could be wrong. 

 

Thanks for looking


#2

Thanks, yes, just a typo, they were set as methods by mistake. Should be OK now!


#3

Amazing speed. Never fails to impress! Many thanks