Commit: r2353: A few tests for WanMil's style functions.

Version 2353 was commited by steve on 2012-10-31 14:15:43 +0000 (Wed, 31 Oct 2012) A few tests for WanMil's style functions.

Version 2353 was commited by steve on 2012-10-31 14:15:43 +0000 (Wed, 31 Oct 2012)
A few tests for WanMil's style functions.
Thanks for adding these tests. Do you think a "negative" test would also be good? @Test public void testNoFunctionParameters() { // a parameter in a function is not allowed yet try { // this should throw a SyntaxException makeRuleSet("A=B & length(a) > 91 [0x5]"); assertTrue("Function with parameters are not allowed", false); } catch (SyntaxException exp) { } } WanMil

On 31/10/12 15:55, WanMil wrote:
Version 2353 was commited by steve on 2012-10-31 14:15:43 +0000 (Wed, 31 Oct 2012)
A few tests for WanMil's style functions.
Thanks for adding these tests.
Do you think a "negative" test would also be good?
Thanks, I can add that. I've been looking into making functions a kind of ValueOp so they can be compiled rather than looked up at run time, as I think you mentioned before. I can then convert normal tag match highway=primary to get_tag(highway)=primary behind the scenes, so that everything looks consistent. This also makes it possible to detect and give an error if you use length() by itself, without any tag matches. ..Steve

On 31/10/12 15:55, WanMil wrote:
Version 2353 was commited by steve on 2012-10-31 14:15:43 +0000 (Wed, 31 Oct 2012)
A few tests for WanMil's style functions.
Thanks for adding these tests.
Do you think a "negative" test would also be good?
Thanks, I can add that.
I've been looking into making functions a kind of ValueOp so they can be compiled rather than looked up at run time, as I think you mentioned before.
I can then convert normal tag match highway=primary to get_tag(highway)=primary behind the scenes, so that everything looks consistent. This also makes it possible to detect and give an error if you use length() by itself, without any tag matches.
Great! I tried to implement that but got stuck. It's easier for you to realize this because you invented the whole style reading and processing. If possible it would be better to allow using length() on its own in a rule. I think sooner or later some style implementors will try rules like: length() < 100 { set specialdistance=short } length() > 100 & length() < 1000 { set specialdistance=medium } length() > 1000 { set specialdistance=long } Anyhow an error would be a good start!
..Steve
WanMil

Hi
If possible it would be better to allow using length() on its own in a rule. I think sooner or later some style implementors will try rules like: length() < 100 { set specialdistance=short } length() > 100 & length() < 1000 { set specialdistance=medium } length() > 1000 { set specialdistance=long }
To run a rule against all elements would have to be a special case, because the way it works is totally driven by the tags on the element.
Anyhow an error would be a good start!
Yes, it should either work, or tell you it doesn't ;) ..Steve
participants (3)
-
Steve Ratcliffe
-
svn commit
-
WanMil