| 121 | check('[!]', '[!]') |
| 122 | |
| 123 | def test_range(self): |
| 124 | check = self.check_match |
| 125 | tescases = string.ascii_lowercase + string.digits + string.punctuation |
| 126 | for c in tescases: |
| 127 | check(c, '[b-d]', c in 'bcd') |
| 128 | check(c, '[!b-d]', c not in 'bcd') |
| 129 | check(c, '[b-dx-z]', c in 'bcdxyz') |
| 130 | check(c, '[!b-dx-z]', c not in 'bcdxyz') |
| 131 | # Case insensitive. |
| 132 | for c in tescases: |
| 133 | check(c, '[B-D]', (c in 'bcd') and IGNORECASE) |
| 134 | check(c, '[!B-D]', (c not in 'bcd') or not IGNORECASE) |
| 135 | for c in string.ascii_uppercase: |
| 136 | check(c, '[b-d]', (c in 'BCD') and IGNORECASE) |
| 137 | check(c, '[!b-d]', (c not in 'BCD') or not IGNORECASE) |
| 138 | # Upper bound == lower bound. |
| 139 | for c in tescases: |
| 140 | check(c, '[b-b]', c == 'b') |
| 141 | # Special cases. |
| 142 | for c in tescases: |
| 143 | check(c, '[!-#]', c not in '-#') |
| 144 | check(c, '[!--.]', c not in '-.') |
| 145 | check(c, '[^-`]', c in '^_`') |
| 146 | if not (NORMSEP and c == '/'): |
| 147 | check(c, '[[-^]', c in r'[\]^') |
| 148 | check(c, r'[\-^]', c in r'\]^') |
| 149 | check(c, '[b-]', c in '-b') |
| 150 | check(c, '[!b-]', c not in '-b') |
| 151 | check(c, '[-b]', c in '-b') |
| 152 | check(c, '[!-b]', c not in '-b') |
| 153 | check(c, '[-]', c in '-') |
| 154 | check(c, '[!-]', c not in '-') |
| 155 | # Upper bound is less that lower bound: error in RE. |
| 156 | for c in tescases: |
| 157 | check(c, '[d-b]', False) |
| 158 | check(c, '[!d-b]', True) |
| 159 | check(c, '[d-bx-z]', c in 'xyz') |
| 160 | check(c, '[!d-bx-z]', c not in 'xyz') |
| 161 | check(c, '[d-b^-`]', c in '^_`') |
| 162 | if not (NORMSEP and c == '/'): |
| 163 | check(c, '[d-b[-^]', c in r'[\]^') |
| 164 | |
| 165 | def test_sep_in_char_set(self): |
| 166 | check = self.check_match |