@@ -437,8 +437,91 @@ describe("descriptors", () => {
437437 } ) ;
438438 } ) ;
439439
440- it ( "instance property - addition is ambiguous" , ( ) => {
441- const [ desc ] = getDescriptor ( "var a = 1, b = 2; (a + b).foo;" , "property" ) ;
440+ it ( "instance property - addition of two numbers produces number" , ( ) => {
441+ const [ desc ] = getDescriptor ( "(1 + 2).toFixed;" ) ;
442+
443+ expect ( desc ) . toEqual ( {
444+ kind : "property" ,
445+ object : "Number" ,
446+ key : "toFixed" ,
447+ placement : "prototype" ,
448+ } ) ;
449+ } ) ;
450+
451+ it ( "instance property - addition with string produces string" , ( ) => {
452+ const [ desc ] = getDescriptor ( '("a" + 1).includes;' ) ;
453+
454+ expect ( desc ) . toEqual ( {
455+ kind : "property" ,
456+ object : "String" ,
457+ key : "includes" ,
458+ placement : "prototype" ,
459+ } ) ;
460+ } ) ;
461+
462+ it ( "instance property - addition string on right produces string" , ( ) => {
463+ const [ desc ] = getDescriptor ( '(1 + "b").includes;' ) ;
464+
465+ expect ( desc ) . toEqual ( {
466+ kind : "property" ,
467+ object : "String" ,
468+ key : "includes" ,
469+ placement : "prototype" ,
470+ } ) ;
471+ } ) ;
472+
473+ it ( "instance property - addition of two strings produces string" , ( ) => {
474+ const [ desc ] = getDescriptor ( '("a" + "b").includes;' ) ;
475+
476+ expect ( desc ) . toEqual ( {
477+ kind : "property" ,
478+ object : "String" ,
479+ key : "includes" ,
480+ placement : "prototype" ,
481+ } ) ;
482+ } ) ;
483+
484+ it ( "instance property - addition of template literal and number produces string" , ( ) => {
485+ const [ desc ] = getDescriptor ( "(`a` + 1).includes;" ) ;
486+
487+ expect ( desc ) . toEqual ( {
488+ kind : "property" ,
489+ object : "String" ,
490+ key : "includes" ,
491+ placement : "prototype" ,
492+ } ) ;
493+ } ) ;
494+
495+ it ( "instance property - addition of two bigints produces bigint" , ( ) => {
496+ const [ desc ] = getDescriptor ( "(1n + 2n).toString;" ) ;
497+
498+ expect ( desc ) . toEqual ( {
499+ kind : "property" ,
500+ object : "BigInt" ,
501+ key : "toString" ,
502+ placement : "prototype" ,
503+ } ) ;
504+ } ) ;
505+
506+ it ( "instance property - addition of number variables produces number" , ( ) => {
507+ const [ desc ] = getDescriptor (
508+ "const a = 1, b = 2; (a + b).toFixed;" ,
509+ "property" ,
510+ ) ;
511+
512+ expect ( desc ) . toEqual ( {
513+ kind : "property" ,
514+ object : "Number" ,
515+ key : "toFixed" ,
516+ placement : "prototype" ,
517+ } ) ;
518+ } ) ;
519+
520+ it ( "instance property - addition with unknown operands is ambiguous" , ( ) => {
521+ const [ desc ] = getDescriptor (
522+ "var a; var b; (a + b).foo;" ,
523+ "property" ,
524+ ) ;
442525
443526 expect ( desc ) . toEqual ( {
444527 kind : "property" ,
0 commit comments