(t *testing.T)
| 3149 | } |
| 3150 | |
| 3151 | func TestRecursionLimit(t *testing.T) { |
| 3152 | const depth = 32 |
| 3153 | recursionDepthTestCases := []struct { |
| 3154 | name string |
| 3155 | source string |
| 3156 | antlrMinRecursionDepth int |
| 3157 | prattMinRecursionDepth int |
| 3158 | }{ |
| 3159 | { |
| 3160 | name: "LargeCalc", |
| 3161 | source: "1" + strings.Repeat(" + 1", depth+1), |
| 3162 | antlrMinRecursionDepth: depth + 1, |
| 3163 | prattMinRecursionDepth: depth + 1, |
| 3164 | }, |
| 3165 | { |
| 3166 | name: "NestedParens", |
| 3167 | source: wrapInParens("7", depth), |
| 3168 | antlrMinRecursionDepth: depth + 1, |
| 3169 | prattMinRecursionDepth: depth, |
| 3170 | }, |
| 3171 | { |
| 3172 | name: "NestedParensWithCalc", |
| 3173 | source: wrapInParens("7", depth) + " + " + wrapInParens("7", depth-1), |
| 3174 | antlrMinRecursionDepth: depth + 1, |
| 3175 | prattMinRecursionDepth: depth, |
| 3176 | }, |
| 3177 | { |
| 3178 | name: "FieldSelections", |
| 3179 | source: "a" + strings.Repeat(".f", depth+1), |
| 3180 | antlrMinRecursionDepth: depth + 1, |
| 3181 | prattMinRecursionDepth: depth + 1, |
| 3182 | }, |
| 3183 | { |
| 3184 | name: "IndexOperations", |
| 3185 | source: "a" + strings.Repeat("[1]", depth+1), |
| 3186 | antlrMinRecursionDepth: depth + 1, |
| 3187 | prattMinRecursionDepth: depth + 1, |
| 3188 | }, |
| 3189 | { |
| 3190 | name: "RelationOperators", |
| 3191 | source: "a" + strings.Repeat(" < 1", depth+1), |
| 3192 | antlrMinRecursionDepth: depth + 1, |
| 3193 | prattMinRecursionDepth: depth + 1, |
| 3194 | }, |
| 3195 | { |
| 3196 | name: "IndexRelationOperators", |
| 3197 | source: "a" + strings.Repeat("[1]", 20) + strings.Repeat(" != a"+strings.Repeat("[1]", 20), 13), |
| 3198 | antlrMinRecursionDepth: depth + 1, |
| 3199 | prattMinRecursionDepth: depth + 1, |
| 3200 | }, |
| 3201 | { |
| 3202 | name: "Ternary", |
| 3203 | source: strings.Repeat("a ? b : ", depth+1) + "c", |
| 3204 | antlrMinRecursionDepth: depth + 2, |
| 3205 | prattMinRecursionDepth: depth + 2, |
| 3206 | }, |
| 3207 | { |
| 3208 | name: "TernaryTrueBranchParens", |
nothing calls this directly
no test coverage detected