@@ -209,13 +209,6 @@ function withCheckInfinity(code) {
209209 } ;
210210}
211211
212- function withCheckNaN ( code ) {
213- return {
214- code,
215- options : [ { checkNaN : true } ] ,
216- } ;
217- }
218-
219212test ( {
220213 valid : [
221214 'const foo = Number.NaN;' ,
@@ -288,52 +281,54 @@ test({
288281 'class Foo { Infinity(){}}' ,
289282 'const foo = Infinity;' ,
290283 'const foo = -Infinity;' ,
291- 'const foo = NaN;' ,
292- 'const foo = -NaN;' ,
284+ {
285+ code : 'const foo = NaN' ,
286+ options : [ { checkNaN : false } ] ,
287+ } ,
293288 ] ,
294289 invalid : [
295290 {
296- ... withCheckNaN ( 'const foo = NaN;' ) ,
291+ code : 'const foo = NaN;' ,
297292 output : 'const foo = Number.NaN;' ,
298293 errors : errorNaN ,
299294 } ,
300295 {
301- ... withCheckNaN ( 'if (Number.isNaN(NaN)) {}' ) ,
296+ code : 'if (Number.isNaN(NaN)) {}' ,
302297 output : 'if (Number.isNaN(Number.NaN)) {}' ,
303298 errors : errorNaN ,
304299 } ,
305300 {
306- ... withCheckNaN ( 'if (Object.is(foo, NaN)) {}' ) ,
301+ code : 'if (Object.is(foo, NaN)) {}' ,
307302 output : 'if (Object.is(foo, Number.NaN)) {}' ,
308303 errors : errorNaN ,
309304 } ,
310305 {
311- ... withCheckNaN ( 'const foo = bar[NaN];' ) ,
306+ code : 'const foo = bar[NaN];' ,
312307 output : 'const foo = bar[Number.NaN];' ,
313308 errors : errorNaN ,
314309 } ,
315310 {
316- ... withCheckNaN ( 'const foo = {NaN};' ) ,
311+ code : 'const foo = {NaN};' ,
317312 output : 'const foo = {NaN: Number.NaN};' ,
318313 errors : errorNaN ,
319314 } ,
320315 {
321- ... withCheckNaN ( 'const foo = {NaN: NaN};' ) ,
316+ code : 'const foo = {NaN: NaN};' ,
322317 output : 'const foo = {NaN: Number.NaN};' ,
323318 errors : errorNaN ,
324319 } ,
325320 {
326- ... withCheckNaN ( 'const {foo = NaN} = {};' ) ,
321+ code : 'const {foo = NaN} = {};' ,
327322 output : 'const {foo = Number.NaN} = {};' ,
328323 errors : errorNaN ,
329324 } ,
330325 {
331- ... withCheckNaN ( 'const foo = NaN.toString();' ) ,
326+ code : 'const foo = NaN.toString();' ,
332327 output : 'const foo = Number.NaN.toString();' ,
333328 errors : errorNaN ,
334329 } ,
335330 {
336- ... withCheckNaN ( 'class Foo3 {[NaN] = 1}' ) ,
331+ code : 'class Foo3 {[NaN] = 1}' ,
337332 output : 'class Foo3 {[Number.NaN] = 1}' ,
338333 errors : errorNaN ,
339334 } ,
@@ -356,7 +351,7 @@ test.babel({
356351 ] ,
357352 invalid : [
358353 {
359- ... withCheckNaN ( 'class Foo2 {[NaN] = 1}' ) ,
354+ code : 'class Foo2 {[NaN] = 1}' ,
360355 output : 'class Foo2 {[Number.NaN] = 1}' ,
361356 errors : 1 ,
362357 } ,
@@ -391,7 +386,7 @@ test.typescript({
391386 ] ,
392387 invalid : [
393388 {
394- ... withCheckNaN ( 'class Foo {[NaN] = 1}' ) ,
389+ code : 'class Foo {[NaN] = 1}' ,
395390 output : 'class Foo {[Number.NaN] = 1}' ,
396391 errors : 1 ,
397392 } ,
@@ -405,11 +400,11 @@ test.snapshot({
405400 'const foo = -(--Infinity);' ,
406401 ] ,
407402 invalid : [
408- withCheckNaN ( 'const foo = {[NaN]: 1}' ) ,
409- withCheckNaN ( 'const foo = {[NaN]() {}}' ) ,
410- withCheckNaN ( 'foo[NaN] = 1;' ) ,
411- withCheckNaN ( 'class A {[NaN](){}}' ) ,
412- withCheckNaN ( 'foo = {[NaN]: 1}' ) ,
403+ 'const foo = {[NaN]: 1}' ,
404+ 'const foo = {[NaN]() {}}' ,
405+ 'foo[NaN] = 1;' ,
406+ 'class A {[NaN](){}}' ,
407+ 'foo = {[NaN]: 1}' ,
413408 withCheckInfinity ( 'const foo = Infinity;' ) ,
414409 withCheckInfinity ( 'if (Number.isNaN(Infinity)) {}' ) ,
415410 withCheckInfinity ( 'if (Object.is(foo, Infinity)) {}' ) ,
@@ -432,12 +427,12 @@ test.snapshot({
432427 withCheckInfinity ( 'const foo = 1 - -Infinity;' ) ,
433428 withCheckInfinity ( 'const isPositiveZero = value => value === 0 && 1 / value === Infinity;' ) ,
434429 withCheckInfinity ( 'const isNegativeZero = value => value === 0 && 1 / value === -Infinity;' ) ,
435- withCheckNaN ( 'const {a = NaN} = {};' ) ,
436- withCheckNaN ( 'const {[NaN]: a = NaN} = {};' ) ,
437- withCheckNaN ( 'const [a = NaN] = [];' ) ,
438- withCheckNaN ( 'function foo({a = NaN}) {}' ) ,
439- withCheckNaN ( 'function foo({[NaN]: a = NaN}) {}' ) ,
440- withCheckNaN ( 'function foo([a = NaN]) {}' ) ,
430+ 'const {a = NaN} = {};' ,
431+ 'const {[NaN]: a = NaN} = {};' ,
432+ 'const [a = NaN] = [];' ,
433+ 'function foo({a = NaN}) {}' ,
434+ 'function foo({[NaN]: a = NaN}) {}' ,
435+ 'function foo([a = NaN]) {}' ,
441436
442437 // Space after keywords
443438 withCheckInfinity ( 'function foo() {return-Infinity}' ) ,
@@ -450,7 +445,7 @@ test.snapshot({
450445 'global.parseFloat(foo);' ,
451446 'window.parseFloat(foo);' ,
452447 'self.parseFloat(foo);' ,
453- withCheckNaN ( 'globalThis.NaN' ) ,
448+ 'globalThis.NaN' ,
454449 withCheckInfinity ( '-globalThis.Infinity' ) ,
455450
456451 // Not a call
0 commit comments