From a6f846334349bad972d359230169b3435926c970 Mon Sep 17 00:00:00 2001 From: fisker Date: Tue, 7 May 2024 15:33:24 +0800 Subject: [PATCH] `throw-new-error`: Use snapshot test --- test/snapshots/throw-new-error.mjs.md | 467 ++++++++++++++++++++++++ test/snapshots/throw-new-error.mjs.snap | Bin 0 -> 1015 bytes test/throw-new-error.mjs | 137 ++----- 3 files changed, 490 insertions(+), 114 deletions(-) create mode 100644 test/snapshots/throw-new-error.mjs.md create mode 100644 test/snapshots/throw-new-error.mjs.snap diff --git a/test/snapshots/throw-new-error.mjs.md b/test/snapshots/throw-new-error.mjs.md new file mode 100644 index 0000000000..5de5a7da48 --- /dev/null +++ b/test/snapshots/throw-new-error.mjs.md @@ -0,0 +1,467 @@ +# Snapshot report for `test/throw-new-error.mjs` + +The actual snapshot is saved in `throw-new-error.mjs.snap`. + +Generated by [AVA](https://avajs.dev). + +## invalid(1): throw Error() + +> Input + + `␊ + 1 | throw Error()␊ + ` + +> Output + + `␊ + 1 | throw new Error()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw Error()␊ + | ^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(2): throw (Error)() + +> Input + + `␊ + 1 | throw (Error)()␊ + ` + +> Output + + `␊ + 1 | throw new (Error)()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw (Error)()␊ + | ^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(3): throw lib.Error() + +> Input + + `␊ + 1 | throw lib.Error()␊ + ` + +> Output + + `␊ + 1 | throw new lib.Error()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw lib.Error()␊ + | ^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(4): throw lib.mod.Error() + +> Input + + `␊ + 1 | throw lib.mod.Error()␊ + ` + +> Output + + `␊ + 1 | throw new lib.mod.Error()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw lib.mod.Error()␊ + | ^^^^^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(5): throw lib[mod].Error() + +> Input + + `␊ + 1 | throw lib[mod].Error()␊ + ` + +> Output + + `␊ + 1 | throw new lib[mod].Error()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw lib[mod].Error()␊ + | ^^^^^^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(6): throw (lib.mod).Error() + +> Input + + `␊ + 1 | throw (lib.mod).Error()␊ + ` + +> Output + + `␊ + 1 | throw new (lib.mod).Error()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw (lib.mod).Error()␊ + | ^^^^^^^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(7): throw Error('foo') + +> Input + + `␊ + 1 | throw Error('foo')␊ + ` + +> Output + + `␊ + 1 | throw new Error('foo')␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw Error('foo')␊ + | ^^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(8): throw CustomError('foo') + +> Input + + `␊ + 1 | throw CustomError('foo')␊ + ` + +> Output + + `␊ + 1 | throw new CustomError('foo')␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw CustomError('foo')␊ + | ^^^^^^^^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(9): throw FooBarBazError('foo') + +> Input + + `␊ + 1 | throw FooBarBazError('foo')␊ + ` + +> Output + + `␊ + 1 | throw new FooBarBazError('foo')␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw FooBarBazError('foo')␊ + | ^^^^^^^^^^^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(10): throw ABCError('foo') + +> Input + + `␊ + 1 | throw ABCError('foo')␊ + ` + +> Output + + `␊ + 1 | throw new ABCError('foo')␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw ABCError('foo')␊ + | ^^^^^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(11): throw Abc3Error('foo') + +> Input + + `␊ + 1 | throw Abc3Error('foo')␊ + ` + +> Output + + `␊ + 1 | throw new Abc3Error('foo')␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw Abc3Error('foo')␊ + | ^^^^^^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(12): throw TypeError() + +> Input + + `␊ + 1 | throw TypeError()␊ + ` + +> Output + + `␊ + 1 | throw new TypeError()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw TypeError()␊ + | ^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(13): throw EvalError() + +> Input + + `␊ + 1 | throw EvalError()␊ + ` + +> Output + + `␊ + 1 | throw new EvalError()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw EvalError()␊ + | ^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(14): throw RangeError() + +> Input + + `␊ + 1 | throw RangeError()␊ + ` + +> Output + + `␊ + 1 | throw new RangeError()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw RangeError()␊ + | ^^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(15): throw ReferenceError() + +> Input + + `␊ + 1 | throw ReferenceError()␊ + ` + +> Output + + `␊ + 1 | throw new ReferenceError()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw ReferenceError()␊ + | ^^^^^^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(16): throw SyntaxError() + +> Input + + `␊ + 1 | throw SyntaxError()␊ + ` + +> Output + + `␊ + 1 | throw new SyntaxError()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw SyntaxError()␊ + | ^^^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(17): throw URIError() + +> Input + + `␊ + 1 | throw URIError()␊ + ` + +> Output + + `␊ + 1 | throw new URIError()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw URIError()␊ + | ^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(18): throw (( URIError() )) + +> Input + + `␊ + 1 | throw (( URIError() ))␊ + ` + +> Output + + `␊ + 1 | throw (( new URIError() ))␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw (( URIError() ))␊ + | ^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(19): throw (( URIError ))() + +> Input + + `␊ + 1 | throw (( URIError ))()␊ + ` + +> Output + + `␊ + 1 | throw new (( URIError ))()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw (( URIError ))()␊ + | ^^^^^^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(20): throw getGlobalThis().Error() + +> Input + + `␊ + 1 | throw getGlobalThis().Error()␊ + ` + +> Output + + `␊ + 1 | throw new (getGlobalThis().Error)()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw getGlobalThis().Error()␊ + | ^^^^^^^^^^^^^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(21): throw utils.getGlobalThis().Error() + +> Input + + `␊ + 1 | throw utils.getGlobalThis().Error()␊ + ` + +> Output + + `␊ + 1 | throw new (utils.getGlobalThis().Error)()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw utils.getGlobalThis().Error()␊ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` + +## invalid(22): throw (( getGlobalThis().Error ))() + +> Input + + `␊ + 1 | throw (( getGlobalThis().Error ))()␊ + ` + +> Output + + `␊ + 1 | throw new (( getGlobalThis().Error ))()␊ + ` + +> Error 1/1 + + `␊ + > 1 | throw (( getGlobalThis().Error ))()␊ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use \`new\` when throwing an error.␊ + ` diff --git a/test/snapshots/throw-new-error.mjs.snap b/test/snapshots/throw-new-error.mjs.snap new file mode 100644 index 0000000000000000000000000000000000000000..740e4683ae572914755cffcd32a09ef86aa71046 GIT binary patch literal 1015 zcmV<6krDJTo~5 z)-)Y-yB~`P00000000BE*j-Q4P#gwuh%qMId0`Y$IJ~(IbWji#6E#545HEf`+4X+@so@(cFwLpKd(P**XQie<()&; zX>j*CV7ql@xr|@NO5I}mVqATxNRdp#_#VQwMKKDc2*D8vB^gGR zeMoNti%1eMxoDn-G>Z|9W0yCS|-wPP|7*1cwIOS(T!K6HmDM}Eq2`vXW zokr%9Qdp>YUV+dvVAzj|_3%1L!Ra1cu_!_w%_>l^ORS9Du!<{()Kn<- zCX!lf`+?WgdzE0w46a$uQ)&y)FeRxeThPvf8Vl@*3he`z$FUGPE=P_ZJ#W=&ty;hI zl)C>NSwU$oK}kW<)DO1J1ud$f|6^O5Vy>Y83uw+1J|S=L~>BK;bi%=c#v zj#d#<90yj)l|?RB5MsdjU}jPIu_I zgrf>jjYGp%P{Xv6tQW6AOmR@y-P%xMJ%iCcg6kDIN@@m@Pb4WRjZ6m+{{l?0C~ee} z|D!k`7)I@qYe2~lJc%X;5r^x&-7;mzisWm^ly+C?EOVKn zBmG<^74&H?n~C1uimiX02cI0TY&km(+cz|CLl)rzra?hbLSZgL&8&<`cBxd)pzR1$ zRfD?maFxq=J~9@Egmz#%ekrxIj!0WYd4GU1Q})(0s?`5LX9v{v159Dx!#l7LpCrg3 lDP|1a9ne-$ci