| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -270,8 +270,19 @@ class TapParser extends Transform { | |||
| 270 | 270 | this.#yamlCurrentIndentationLevel = this.#subTestNestingLevel; | |
| 271 | 271 | } | |
| 272 | 272 | ||
| 273 | + let node; | ||
| 274 | + | ||
| 273 | 275 | // Parse current chunk | |
| 274 | - const node = this.#TAPDocument(chunk); | ||
| 276 | + try { | ||
| 277 | + node = this.#TAPDocument(chunk); | ||
| 278 | + } catch { | ||
| 279 | + node = { | ||
| 280 | + kind: TokenKind.UNKNOWN, | ||
| 281 | + node: { | ||
| 282 | + value: this.#currentChunkAsString, | ||
| 283 | + }, | ||
| 284 | + }; | ||
| 285 | + } | ||
| 275 | 286 | ||
| 276 | 287 | // Emit the parsed node to both the stream and the AST | |
| 277 | 288 | this.#emitOrBufferCurrentNode(node); | |
@@ -282,12 +293,6 @@ class TapParser extends Transform { | |||
| 282 | 293 | } | |
| 283 | 294 | ||
| 284 | 295 | #error(message) { | |
| 285 | - if (!this.#isSyncParsingEnabled) { | ||
| 286 | - // When async parsing is enabled, don't throw. | ||
| 287 | - // Unrecognized tokens would be ignored. | ||
| 288 | - return; | ||
| 289 | - } | ||
| 290 | - | ||
| 291 | 296 | const token = this.#currentToken || { value: '', kind: '' }; | |
| 292 | 297 | // Escape NewLine characters | |
| 293 | 298 | if (token.value === '\n') { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,6 +17,193 @@ const cases = [ | |||
| 17 | 17 | }, | |
| 18 | 18 | ], | |
| 19 | 19 | }, | |
| 20 | + { | ||
| 21 | + input: '123', | ||
| 22 | + expected: [ | ||
| 23 | + { | ||
| 24 | + kind: 'Unknown', | ||
| 25 | + node: { value: '123' }, | ||
| 26 | + nesting: 0, | ||
| 27 | + lexeme: '123', | ||
| 28 | + }, | ||
| 29 | + ], | ||
| 30 | + }, | ||
| 31 | + { | ||
| 32 | + input: '# 123', | ||
| 33 | + expected: [ | ||
| 34 | + { | ||
| 35 | + kind: 'Comment', | ||
| 36 | + node: { comment: '123' }, | ||
| 37 | + nesting: 0, | ||
| 38 | + lexeme: '# 123', | ||
| 39 | + }, | ||
| 40 | + ], | ||
| 41 | + }, | ||
| 42 | + { | ||
| 43 | + input: '1..', | ||
| 44 | + expected: [ | ||
| 45 | + { | ||
| 46 | + kind: 'Unknown', | ||
| 47 | + node: { value: '1..' }, | ||
| 48 | + nesting: 0, | ||
| 49 | + lexeme: '1..', | ||
| 50 | + }, | ||
| 51 | + ], | ||
| 52 | + }, | ||
| 53 | + { | ||
| 54 | + input: '1..abc', | ||
| 55 | + expected: [ | ||
| 56 | + { | ||
| 57 | + kind: 'Unknown', | ||
| 58 | + node: { value: '1..abc' }, | ||
| 59 | + nesting: 0, | ||
| 60 | + lexeme: '1..abc', | ||
| 61 | + }, | ||
| 62 | + ], | ||
| 63 | + }, | ||
| 64 | + { | ||
| 65 | + input: '1..-1', | ||
| 66 | + expected: [ | ||
| 67 | + { | ||
| 68 | + kind: 'Unknown', | ||
| 69 | + node: { value: '1..-1' }, | ||
| 70 | + nesting: 0, | ||
| 71 | + lexeme: '1..-1', | ||
| 72 | + }, | ||
| 73 | + ], | ||
| 74 | + }, | ||
| 75 | + { | ||
| 76 | + input: '1.1', | ||
| 77 | + expected: [ | ||
| 78 | + { | ||
| 79 | + kind: 'Unknown', | ||
| 80 | + node: { value: '1.1' }, | ||
| 81 | + nesting: 0, | ||
| 82 | + lexeme: '1.1', | ||
| 83 | + }, | ||
| 84 | + ], | ||
| 85 | + }, | ||
| 86 | + { | ||
| 87 | + input: '1.....4', | ||
| 88 | + expected: [ | ||
| 89 | + { | ||
| 90 | + kind: 'Unknown', | ||
| 91 | + node: { value: '1.....4' }, | ||
| 92 | + nesting: 0, | ||
| 93 | + lexeme: '1.....4', | ||
| 94 | + }, | ||
| 95 | + ], | ||
| 96 | + }, | ||
| 97 | + { | ||
| 98 | + input: 'TAP 12', | ||
| 99 | + expected: [ | ||
| 100 | + { | ||
| 101 | + kind: 'Unknown', | ||
| 102 | + node: { value: 'TAP 12' }, | ||
| 103 | + nesting: 0, | ||
| 104 | + lexeme: 'TAP 12', | ||
| 105 | + }, | ||
| 106 | + ], | ||
| 107 | + }, | ||
| 108 | + { | ||
| 109 | + input: 'TAP version', | ||
| 110 | + expected: [ | ||
| 111 | + { | ||
| 112 | + kind: 'Unknown', | ||
| 113 | + node: { value: 'TAP version' }, | ||
| 114 | + nesting: 0, | ||
| 115 | + lexeme: 'TAP version', | ||
| 116 | + }, | ||
| 117 | + ], | ||
| 118 | + }, | ||
| 119 | + { | ||
| 120 | + input: 'TAP version v14', | ||
| 121 | + expected: [ | ||
| 122 | + { | ||
| 123 | + kind: 'Unknown', | ||
| 124 | + node: { value: 'TAP version v14' }, | ||
| 125 | + nesting: 0, | ||
| 126 | + lexeme: 'TAP version v14', | ||
| 127 | + }, | ||
| 128 | + ], | ||
| 129 | + }, | ||
| 130 | + { | ||
| 131 | + input: 'TAP TAP TAP', | ||
| 132 | + expected: [ | ||
| 133 | + { | ||
| 134 | + kind: 'Unknown', | ||
| 135 | + node: { value: 'TAP TAP TAP' }, | ||
| 136 | + nesting: 0, | ||
| 137 | + lexeme: 'TAP TAP TAP', | ||
| 138 | + }, | ||
| 139 | + ], | ||
| 140 | + }, | ||
| 141 | + { | ||
| 142 | + input: '--- yaml', | ||
| 143 | + expected: [ | ||
| 144 | + { | ||
| 145 | + kind: 'Unknown', | ||
| 146 | + node: { value: '--- yaml' }, | ||
| 147 | + nesting: 0, | ||
| 148 | + lexeme: '--- yaml', | ||
| 149 | + }, | ||
| 150 | + ], | ||
| 151 | + }, | ||
| 152 | + { | ||
| 153 | + input: '... ... yaml', | ||
| 154 | + expected: [ | ||
| 155 | + { | ||
| 156 | + kind: 'Unknown', | ||
| 157 | + node: { value: '... ... yaml' }, | ||
| 158 | + nesting: 0, | ||
| 159 | + lexeme: '... ... yaml', | ||
| 160 | + }, | ||
| 161 | + ], | ||
| 162 | + }, | ||
| 163 | + { | ||
| 164 | + input: 'ook 1', | ||
| 165 | + expected: [ | ||
| 166 | + { | ||
| 167 | + kind: 'Unknown', | ||
| 168 | + node: { value: 'ook 1' }, | ||
| 169 | + nesting: 0, | ||
| 170 | + lexeme: 'ook 1', | ||
| 171 | + }, | ||
| 172 | + ], | ||
| 173 | + }, | ||
| 174 | + { | ||
| 175 | + input: ' ok 98', | ||
| 176 | + expected: [ | ||
| 177 | + { | ||
| 178 | + kind: 'Unknown', | ||
| 179 | + node: { value: ' ok 98' }, | ||
| 180 | + nesting: 0, | ||
| 181 | + lexeme: ' ok 98', | ||
| 182 | + }, | ||
| 183 | + ], | ||
| 184 | + }, | ||
| 185 | + { | ||
| 186 | + input: 'pragma ++++++', | ||
| 187 | + expected: [ | ||
| 188 | + { | ||
| 189 | + kind: 'Unknown', | ||
| 190 | + node: { value: 'pragma ++++++' }, | ||
| 191 | + nesting: 0, | ||
| 192 | + lexeme: 'pragma ++++++', | ||
| 193 | + }, | ||
| 194 | + ], | ||
| 195 | + }, | ||
| 196 | + { | ||
| 197 | + input: 'Bailout!', | ||
| 198 | + expected: [ | ||
| 199 | + { | ||
| 200 | + kind: 'Unknown', | ||
| 201 | + node: { value: 'Bailout!' }, | ||
| 202 | + nesting: 0, | ||
| 203 | + lexeme: 'Bailout!', | ||
| 204 | + }, | ||
| 205 | + ], | ||
| 206 | + }, | ||
| 20 | 207 | { | |
| 21 | 208 | input: 'invalid tap', | |
| 22 | 209 | expected: [ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments