Changeset 7115 in josm


Ignore:
Timestamp:
2014-05-12T23:07:55+02:00 (10 years ago)
Author:
simon04
Message:

fix #9783 - MapCSS: allow to regexp-match name=(foo) by [name =~ /\(foo\)/]

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj

    r7064 r7115  
    134134|   < STRING: "\"" ( [" ","!","#"-"[","]"-"~","\u0080"-"\uFFFF"] | "\\\"" | "\\\\" )*  "\"" >
    135135|   < #PREDEFINED: "\\" ["d","D","s","S","w","W"] >
    136 |   < #REGEX_CHAR_WITHOUT_STAR: [" "-")","+"-".","0"-"[","]"-"~","\u0080"-"\uFFFF"] | "\\/" | "\\\\" | "\\[" | "\\]" | "\\+" | "\\." | "\\'" | "\\\"" | <PREDEFINED> >
     136|   < #REGEX_CHAR_WITHOUT_STAR: [" "-")","+"-".","0"-"[","]"-"~","\u0080"-"\uFFFF"] | "\\/" | "\\\\" | "\\[" | "\\]" | "\\+" | "\\." | "\\'" | "\\\"" |  "\\(" | "\\)" |<PREDEFINED> >
    137137|   < REGEX: "/" <REGEX_CHAR_WITHOUT_STAR> ( <REGEX_CHAR_WITHOUT_STAR> | "*" )*  "/" >
    138138|   < LBRACE: "{" >
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.groovy

    r7081 r7115  
    113113
    114114    @Test
     115    public void testRegexConditionParenthesis() throws Exception {
     116        def condition = (Condition.KeyValueCondition) getParser("[name =~ /^\\(foo\\)/]").condition(Condition.Context.PRIMITIVE)
     117        assert condition.applies(getEnvironment("name", "(foo)"))
     118        assert !condition.applies(getEnvironment("name", "foo"))
     119        assert !condition.applies(getEnvironment("name", "((foo))"))
     120    }
     121
     122    @Test
    115123    public void testNegatedRegexCondition() throws Exception {
    116124        def condition = (Condition.KeyValueCondition) getParser("[surface!~/paved|unpaved/]").condition(Condition.Context.PRIMITIVE)
Note: See TracChangeset for help on using the changeset viewer.