@@ -108,7 +108,7 @@ describe("decode", () => {
108
108
assertEquals ( decode ( map ) , info ) ;
109
109
} ) ;
110
110
111
- it ( "ignores wrong 'name' indices" , ( ) => {
111
+ it ( "ignores wrong 'name' indices in lax mode " , ( ) => {
112
112
const encoder = new ItemEncoder ( ) ;
113
113
encoder . addUnsignedVLQs (
114
114
Tag . ORIGINAL_SCOPE_START ,
@@ -122,10 +122,10 @@ describe("decode", () => {
122
122
const info = decode ( map ) ;
123
123
124
124
assertExists ( info . scopes [ 0 ] ) ;
125
- assertStrictEquals ( info . scopes [ 0 ] . name , undefined ) ;
125
+ assertStrictEquals ( info . scopes [ 0 ] . name , "" ) ;
126
126
} ) ;
127
127
128
- it ( "ignores wrong 'kind' indices" , ( ) => {
128
+ it ( "ignores wrong 'kind' indices in lax mode " , ( ) => {
129
129
const encoder = new ItemEncoder ( ) ;
130
130
encoder . addUnsignedVLQs (
131
131
Tag . ORIGINAL_SCOPE_START ,
@@ -139,7 +139,7 @@ describe("decode", () => {
139
139
const info = decode ( map ) ;
140
140
141
141
assertExists ( info . scopes [ 0 ] ) ;
142
- assertStrictEquals ( info . scopes [ 0 ] . kind , undefined ) ;
142
+ assertStrictEquals ( info . scopes [ 0 ] . kind , "" ) ;
143
143
} ) ;
144
144
145
145
it ( "throws when encountering an ORIGINAL_SCOPE_END without start in strict mode" , ( ) => {
@@ -258,7 +258,7 @@ describe("decode", () => {
258
258
assertEquals ( info . scopes , [ ] ) ;
259
259
} ) ;
260
260
261
- it ( "throws if ORIGINAL_SCOPE_VARIABLES indices are out-of-bounds (upper)" , ( ) => {
261
+ it ( "throws if ORIGINAL_SCOPE_VARIABLES indices are out-of-bounds (upper) in strict mode " , ( ) => {
262
262
const encoder = new ItemEncoder ( ) ;
263
263
encoder . addUnsignedVLQs ( Tag . ORIGINAL_SCOPE_START , 0 , 0 , 0 ) . finishItem ( ) ;
264
264
encoder . addUnsignedVLQs ( Tag . ORIGINAL_SCOPE_VARIABLES ) ;
@@ -273,7 +273,7 @@ describe("decode", () => {
273
273
) ;
274
274
} ) ;
275
275
276
- it ( "throws if ORIGINAL_SCOPE_VARIABLES indices are out-of-bounds (lower)" , ( ) => {
276
+ it ( "throws if ORIGINAL_SCOPE_VARIABLES indices are out-of-bounds (lower) in strict mode " , ( ) => {
277
277
const encoder = new ItemEncoder ( ) ;
278
278
encoder . addUnsignedVLQs ( Tag . ORIGINAL_SCOPE_START , 0 , 0 , 0 ) . finishItem ( ) ;
279
279
encoder . addUnsignedVLQs ( Tag . ORIGINAL_SCOPE_VARIABLES ) ;
@@ -288,7 +288,7 @@ describe("decode", () => {
288
288
) ;
289
289
} ) ;
290
290
291
- it ( "ignores if ORIGINAL_SCOPE_VARIABLES indices are out-of-bounds (upper)" , ( ) => {
291
+ it ( "ignores if ORIGINAL_SCOPE_VARIABLES indices are out-of-bounds (upper) in lax mode " , ( ) => {
292
292
const encoder = new ItemEncoder ( ) ;
293
293
encoder . addUnsignedVLQs ( Tag . ORIGINAL_SCOPE_START , 0 , 0 , 0 ) . finishItem ( ) ;
294
294
encoder . addUnsignedVLQs ( Tag . ORIGINAL_SCOPE_VARIABLES ) ;
@@ -301,7 +301,7 @@ describe("decode", () => {
301
301
assertEquals ( info . scopes [ 0 ] ?. variables , [ "foo" , "" ] ) ;
302
302
} ) ;
303
303
304
- it ( "ignores if ORIGINAL_SCOPE_VARIABLES indices are out-of-bounds (lower)" , ( ) => {
304
+ it ( "ignores if ORIGINAL_SCOPE_VARIABLES indices are out-of-bounds (lower) in lax mode " , ( ) => {
305
305
const encoder = new ItemEncoder ( ) ;
306
306
encoder . addUnsignedVLQs ( Tag . ORIGINAL_SCOPE_START , 0 , 0 , 0 ) . finishItem ( ) ;
307
307
encoder . addUnsignedVLQs ( Tag . ORIGINAL_SCOPE_VARIABLES ) ;
@@ -313,4 +313,40 @@ describe("decode", () => {
313
313
314
314
assertEquals ( info . scopes [ 0 ] ?. variables , [ "foo" , "" ] ) ;
315
315
} ) ;
316
+
317
+ it ( "throws if ORIGINAL_SCOPE_START.name is out-of-bounds in strict mode" , ( ) => {
318
+ const encoder = new ItemEncoder ( ) ;
319
+ encoder . addUnsignedVLQs (
320
+ Tag . ORIGINAL_SCOPE_START ,
321
+ OriginalScopeFlags . HAS_NAME ,
322
+ 0 ,
323
+ 0 ,
324
+ ) . addSignedVLQs ( 1 ) . finishItem ( ) ; // The last '1' is the illegal name index.
325
+ encoder . addUnsignedVLQs ( Tag . ORIGINAL_SCOPE_END , 1 , 0 ) . finishItem ( ) ;
326
+ const map = createMap ( encoder . encode ( ) , [ "foo" ] ) ;
327
+
328
+ assertThrows (
329
+ ( ) => decode ( map , { mode : DecodeMode . STRICT } ) ,
330
+ Error ,
331
+ "index into the 'names' array" ,
332
+ ) ;
333
+ } ) ;
334
+
335
+ it ( "throws if ORIGINAL_SCOPE_START.kind is out-of-bounds in strict mode" , ( ) => {
336
+ const encoder = new ItemEncoder ( ) ;
337
+ encoder . addUnsignedVLQs (
338
+ Tag . ORIGINAL_SCOPE_START ,
339
+ OriginalScopeFlags . HAS_KIND ,
340
+ 0 ,
341
+ 0 ,
342
+ ) . addSignedVLQs ( 1 ) . finishItem ( ) ; // The last '1' is the illegal name index.
343
+ encoder . addUnsignedVLQs ( Tag . ORIGINAL_SCOPE_END , 1 , 0 ) . finishItem ( ) ;
344
+ const map = createMap ( encoder . encode ( ) , [ "foo" ] ) ;
345
+
346
+ assertThrows (
347
+ ( ) => decode ( map , { mode : DecodeMode . STRICT } ) ,
348
+ Error ,
349
+ "index into the 'names' array" ,
350
+ ) ;
351
+ } ) ;
316
352
} ) ;
0 commit comments