@@ -1001,13 +1001,13 @@ describe("accepted equivalent mutants", () => {
10011001 status : "Survived" ,
10021002 mutatorName : "EqualityOperator" ,
10031003 replacement : "<=" ,
1004- location : { start : { line : 45 } } ,
1004+ location : { start : { line : 45 , column : 0 } } ,
10051005 } ,
10061006 {
10071007 status : "Survived" ,
10081008 mutatorName : "ConditionalExpression" ,
10091009 replacement : "true" ,
1010- location : { start : { line : 50 } } ,
1010+ location : { start : { line : 50 , column : 2 } } ,
10111011 } ,
10121012 ] ,
10131013 } ,
@@ -1017,20 +1017,23 @@ describe("accepted equivalent mutants", () => {
10171017 {
10181018 file : "src/utils/pathUtils.ts" ,
10191019 line : 45 ,
1020+ column : 0 ,
10201021 mutator : "EqualityOperator" ,
10211022 replacement : "<=" ,
10221023 reason : "defensive bound never hit" ,
10231024 } ,
10241025 {
10251026 file : "src/utils/pathUtils.ts" ,
10261027 line : 99 ,
1028+ column : 0 ,
10271029 mutator : "BlockStatement" ,
10281030 replacement : "{}" ,
10291031 reason : "entry whose mutant is gone" ,
10301032 } ,
10311033 {
10321034 file : "src/other.ts" ,
10331035 line : 7 ,
1036+ column : 0 ,
10341037 mutator : "Foo" ,
10351038 replacement : "bar" ,
10361039 reason : "file not part of this run" ,
@@ -1054,13 +1057,13 @@ describe("accepted equivalent mutants", () => {
10541057 status : "Survived" ,
10551058 mutatorName : "ConditionalExpression" ,
10561059 replacement : "true" ,
1057- location : { start : { line : 50 } } ,
1060+ location : { start : { line : 50 , column : 2 } } ,
10581061 } ,
10591062 {
10601063 status : "Survived" ,
10611064 mutatorName : "ConditionalExpression" ,
10621065 replacement : "false" ,
1063- location : { start : { line : 50 } } ,
1066+ location : { start : { line : 50 , column : 2 } } ,
10641067 } ,
10651068 ] ,
10661069 } ,
@@ -1070,6 +1073,7 @@ describe("accepted equivalent mutants", () => {
10701073 {
10711074 file : "src/utils/pathUtils.ts" ,
10721075 line : 50 ,
1076+ column : 2 ,
10731077 mutator : "ConditionalExpression" ,
10741078 replacement : "true" ,
10751079 reason : "only the true replacement is equivalent here" ,
@@ -1100,6 +1104,7 @@ describe("accepted equivalent mutants", () => {
11001104 {
11011105 file : "src/utils/pathUtils.ts" ,
11021106 line : 50 ,
1107+ column : 1 ,
11031108 mutator : "ConditionalExpression" ,
11041109 replacement : "true" ,
11051110 reason : "the first sub-expression is equivalent here" ,
@@ -1114,7 +1119,10 @@ describe("accepted equivalent mutants", () => {
11141119 )
11151120 assert . deepEqual ( limited . advisories , [ ] )
11161121
1117- const twoEntries = [ ...oneEntry , { ...oneEntry [ 0 ] , reason : "the second sub-expression is also equivalent" } ]
1122+ const twoEntries = [
1123+ ...oneEntry ,
1124+ { ...oneEntry [ 0 ] , column : 2 , reason : "the second sub-expression is also equivalent" } ,
1125+ ]
11181126 const both = evaluateReport ( threeSameKey , packageEntry , twoEntries )
11191127 assert . equal ( both . equivalent , 2 )
11201128 assert . equal ( both . blocking . length , 1 )
@@ -1139,6 +1147,7 @@ describe("accepted equivalent mutants", () => {
11391147 const oneEntry = {
11401148 file : "src/utils/pathUtils.ts" ,
11411149 line : 50 ,
1150+ column : 1 ,
11421151 mutator : "ConditionalExpression" ,
11431152 replacement : "true" ,
11441153 reason : "only one mutant carries this key" ,
@@ -1210,8 +1219,31 @@ describe("accepted equivalent mutants", () => {
12101219 }
12111220 } )
12121221
1213- it ( "loads no equivalences when the registry file is absent" , ( ) => {
1214- assert . deepEqual ( loadEquivalences ( fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "stryker-eq-" ) ) ) , [ ] )
1222+ it ( "loads no equivalences when the registry file is absent" , ( t ) => {
1223+ const directory = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "stryker-eq-" ) )
1224+ t . after ( ( ) => fs . rmSync ( directory , { recursive : true , force : true } ) )
1225+ assert . deepEqual ( loadEquivalences ( directory ) , [ ] )
1226+ } )
1227+
1228+ it ( "loads entries from a repository registry file" , ( t ) => {
1229+ const directory = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "stryker-eq-present-" ) )
1230+ t . after ( ( ) => fs . rmSync ( directory , { recursive : true , force : true } ) )
1231+ fs . mkdirSync ( path . join ( directory , "scripts" ) , { recursive : true } )
1232+ const entry = {
1233+ file : "src/example.ts" ,
1234+ line : 3 ,
1235+ column : 2 ,
1236+ mutator : "ConditionalExpression" ,
1237+ replacement : "true" ,
1238+ reason : "example reason that is long enough to be reviewable" ,
1239+ }
1240+ fs . writeFileSync (
1241+ path . join ( directory , "scripts/stryker-equivalences.json" ) ,
1242+ JSON . stringify ( { equivalences : [ entry ] } ) ,
1243+ "utf8" ,
1244+ )
1245+
1246+ assert . deepEqual ( loadEquivalences ( directory ) , [ entry ] )
12151247 } )
12161248
12171249 it ( "ships registry entries with file, line, mutator, and reason" , ( ) => {
@@ -1222,6 +1254,7 @@ describe("accepted equivalent mutants", () => {
12221254 for ( const entry of registry ) {
12231255 assert . match ( entry . file , / ^ ( s r c | p a c k a g e s ) \/ / )
12241256 assert . ok ( Number . isInteger ( entry . line ) )
1257+ assert . ok ( Number . isInteger ( entry . column ) && entry . column >= 0 )
12251258 assert . ok ( entry . mutator )
12261259 assert . equal ( typeof entry . replacement , "string" )
12271260 assert . ok ( entry . reason . length > 20 )
@@ -1234,6 +1267,7 @@ describe("accepted equivalent mutants", () => {
12341267 const conditional = {
12351268 file : "src/example.ts" ,
12361269 line : 1 ,
1270+ column : 10 ,
12371271 mutator : "ConditionalExpression" ,
12381272 replacement : "true" ,
12391273 reason : "example" ,
@@ -1246,7 +1280,7 @@ describe("accepted equivalent mutants", () => {
12461280 const driftedObject = { ...conditional , mutator : "ObjectLiteral" , line : 1 }
12471281 assert . match (
12481282 validateEquivalenceEntries ( [ driftedObject ] , readSource ) . join ( "\n" ) ,
1249- / s r c \/ e x a m p l e \. t s : 1 : e x p e c t e d O b j e c t L i t e r a l c o d e a t l i n e 2 / ,
1283+ / s r c \/ e x a m p l e \. t s : 1 : 1 0 : e x p e c t e d O b j e c t L i t e r a l c o d e a t l i n e 2 / ,
12501284 )
12511285
12521286 // ConditionalExpression is a different node kind than the object literal.
@@ -1255,6 +1289,14 @@ describe("accepted equivalent mutants", () => {
12551289 validateEquivalenceEntries ( [ driftedConditional ] , readSource ) . join ( "\n" ) ,
12561290 / e x p e c t e d C o n d i t i o n a l E x p r e s s i o n c o d e a t l i n e 3 / ,
12571291 )
1292+
1293+ // A same-line edit that moves the mutated node must invalidate the entry rather than
1294+ // silently accepting whatever mutant now sits on the recorded line.
1295+ const driftedColumn = { ...conditional , column : 11 }
1296+ assert . match (
1297+ validateEquivalenceEntries ( [ driftedColumn ] , readSource ) . join ( "\n" ) ,
1298+ / s r c \/ e x a m p l e \. t s : 1 : 1 1 : e x p e c t e d C o n d i t i o n a l E x p r e s s i o n c o d e a t l i n e 2 / ,
1299+ )
12581300 } )
12591301
12601302 it ( "rejects an entry with an unknown mutator or missing file" , ( ) => {
0 commit comments