Added test cases for intersection

This commit is contained in:
Napalys
2025-03-02 19:07:43 +01:00
parent 2333c538d9
commit fa5093f6ad
2 changed files with 434 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
/[[abc]&&[bcd]]/v; // Valid use of intersection operator, matches b or c
/abc&&bcd/v; //Valid regex, but no intersection operation: Matches the literal string "abc&&bcd"
/[abc]&&[bcd]/v; // Valid regex, but incorrect intersection operation:
// - Matches a single character from [abc]
// - Then the literal "&&"
// - Then a single character from [bcd]
/[[abc]&&[bcd]&&[c]]/v; // Valid use of intersection operator, matches c

View File

@@ -0,0 +1,427 @@
#10000=@"/intersection.js;sourcefile"
files(#10000,"/intersection.js")
#10001=@"/;folder"
folders(#10001,"/")
containerparent(#10001,#10000)
#10002=@"loc,{#10000},0,0,0,0"
locations_default(#10002,#10000,0,0,0,0)
hasLocation(#10000,#10002)
#20000=@"global_scope"
scopes(#20000,0)
#20001=@"script;{#10000},1,1"
#20002=*
comments(#20002,0,#20001," Valid use of intersection operator, matches b or c","// Vali ... b or c")
#20003=@"loc,{#10000},1,20,1,72"
locations_default(#20003,#10000,1,20,1,72)
hasLocation(#20002,#20003)
#20004=*
comments(#20004,0,#20001,"Valid regex, but no intersection operation: Matches the literal string ""abc&&bcd""","//Valid ... c&&bcd""")
#20005=@"loc,{#10000},2,14,2,96"
locations_default(#20005,#10000,2,14,2,96)
hasLocation(#20004,#20005)
#20006=*
comments(#20006,0,#20001," Valid regex, but incorrect intersection operation: ","// Vali ... ation: ")
#20007=@"loc,{#10000},3,18,3,71"
locations_default(#20007,#10000,3,18,3,71)
hasLocation(#20006,#20007)
#20008=*
comments(#20008,0,#20001," - Matches a single character from [abc]","// - Ma ... m [abc]")
#20009=@"loc,{#10000},4,18,4,59"
locations_default(#20009,#10000,4,18,4,59)
hasLocation(#20008,#20009)
#20010=*
comments(#20010,0,#20001," - Then the literal ""&&""","// - Th ... al ""&&""")
#20011=@"loc,{#10000},5,18,5,43"
locations_default(#20011,#10000,5,18,5,43)
hasLocation(#20010,#20011)
#20012=*
comments(#20012,0,#20001," - Then a single character from [bcd]","// - Th ... m [bcd]")
#20013=@"loc,{#10000},6,18,6,56"
locations_default(#20013,#10000,6,18,6,56)
hasLocation(#20012,#20013)
#20014=*
comments(#20014,0,#20001," Valid use of intersection operator, matches c","// Vali ... tches c")
#20015=@"loc,{#10000},7,25,7,72"
locations_default(#20015,#10000,7,25,7,72)
hasLocation(#20014,#20015)
#20016=*
lines(#20016,#20001,"/[[abc]&&[bcd]]/v; // Valid use of intersection operator, matches b or c","
")
#20017=@"loc,{#10000},1,1,1,72"
locations_default(#20017,#10000,1,1,1,72)
hasLocation(#20016,#20017)
#20018=*
lines(#20018,#20001,"/abc&&bcd/v; //Valid regex, but no intersection operation: Matches the literal string ""abc&&bcd""","
")
#20019=@"loc,{#10000},2,1,2,96"
locations_default(#20019,#10000,2,1,2,96)
hasLocation(#20018,#20019)
#20020=*
lines(#20020,#20001,"/[abc]&&[bcd]/v; // Valid regex, but incorrect intersection operation: ","
")
#20021=@"loc,{#10000},3,1,3,71"
locations_default(#20021,#10000,3,1,3,71)
hasLocation(#20020,#20021)
#20022=*
lines(#20022,#20001," // - Matches a single character from [abc]","
")
#20023=@"loc,{#10000},4,1,4,59"
locations_default(#20023,#10000,4,1,4,59)
hasLocation(#20022,#20023)
indentation(#10000,4," ",17)
#20024=*
lines(#20024,#20001," // - Then the literal ""&&""","
")
#20025=@"loc,{#10000},5,1,5,43"
locations_default(#20025,#10000,5,1,5,43)
hasLocation(#20024,#20025)
indentation(#10000,5," ",17)
#20026=*
lines(#20026,#20001," // - Then a single character from [bcd]","
")
#20027=@"loc,{#10000},6,1,6,56"
locations_default(#20027,#10000,6,1,6,56)
hasLocation(#20026,#20027)
indentation(#10000,6," ",17)
#20028=*
lines(#20028,#20001,"/[[abc]&&[bcd]&&[c]]/v; // Valid use of intersection operator, matches c","
")
#20029=@"loc,{#10000},7,1,7,72"
locations_default(#20029,#10000,7,1,7,72)
hasLocation(#20028,#20029)
numlines(#20001,7,4,7)
#20030=*
tokeninfo(#20030,5,#20001,0,"/[[abc]&&[bcd]]/v")
#20031=@"loc,{#10000},1,1,1,17"
locations_default(#20031,#10000,1,1,1,17)
hasLocation(#20030,#20031)
#20032=*
tokeninfo(#20032,8,#20001,1,";")
#20033=@"loc,{#10000},1,18,1,18"
locations_default(#20033,#10000,1,18,1,18)
hasLocation(#20032,#20033)
#20034=*
tokeninfo(#20034,5,#20001,2,"/abc&&bcd/v")
#20035=@"loc,{#10000},2,1,2,11"
locations_default(#20035,#10000,2,1,2,11)
hasLocation(#20034,#20035)
next_token(#20002,#20034)
#20036=*
tokeninfo(#20036,8,#20001,3,";")
#20037=@"loc,{#10000},2,12,2,12"
locations_default(#20037,#10000,2,12,2,12)
hasLocation(#20036,#20037)
#20038=*
tokeninfo(#20038,5,#20001,4,"/[abc]&&[bcd]/v")
#20039=@"loc,{#10000},3,1,3,15"
locations_default(#20039,#10000,3,1,3,15)
hasLocation(#20038,#20039)
next_token(#20004,#20038)
#20040=*
tokeninfo(#20040,8,#20001,5,";")
#20041=@"loc,{#10000},3,16,3,16"
locations_default(#20041,#10000,3,16,3,16)
hasLocation(#20040,#20041)
#20042=*
tokeninfo(#20042,5,#20001,6,"/[[abc]&&[bcd]&&[c]]/v")
#20043=@"loc,{#10000},7,1,7,22"
locations_default(#20043,#10000,7,1,7,22)
hasLocation(#20042,#20043)
next_token(#20006,#20042)
next_token(#20008,#20042)
next_token(#20010,#20042)
next_token(#20012,#20042)
#20044=*
tokeninfo(#20044,8,#20001,7,";")
#20045=@"loc,{#10000},7,23,7,23"
locations_default(#20045,#10000,7,23,7,23)
hasLocation(#20044,#20045)
#20046=*
tokeninfo(#20046,0,#20001,8,"")
#20047=@"loc,{#10000},8,1,8,0"
locations_default(#20047,#10000,8,1,8,0)
hasLocation(#20046,#20047)
next_token(#20014,#20046)
toplevels(#20001,0)
#20048=@"loc,{#10000},1,1,8,0"
locations_default(#20048,#10000,1,1,8,0)
hasLocation(#20001,#20048)
#20049=*
stmts(#20049,2,#20001,0,"/[[abc]&&[bcd]]/v;")
#20050=@"loc,{#10000},1,1,1,18"
locations_default(#20050,#10000,1,1,1,18)
hasLocation(#20049,#20050)
stmt_containers(#20049,#20001)
#20051=*
exprs(#20051,5,#20049,0,"/[[abc]&&[bcd]]/v")
hasLocation(#20051,#20031)
enclosing_stmt(#20051,#20049)
expr_containers(#20051,#20001)
literals("/[[abc]&&[bcd]]/v","/[[abc]&&[bcd]]/v",#20051)
#20052=*
regexpterm(#20052,23,#20051,0,"[[abc]&&[bcd]]")
#20053=@"loc,{#10000},1,2,1,15"
locations_default(#20053,#10000,1,2,1,15)
hasLocation(#20052,#20053)
#20054=*
regexpterm(#20054,23,#20052,0,"[abc]")
#20055=@"loc,{#10000},1,3,1,7"
locations_default(#20055,#10000,1,3,1,7)
hasLocation(#20054,#20055)
#20056=*
regexpterm(#20056,14,#20054,0,"a")
#20057=@"loc,{#10000},1,4,1,4"
locations_default(#20057,#10000,1,4,1,4)
hasLocation(#20056,#20057)
regexp_const_value(#20056,"a")
#20058=*
regexpterm(#20058,14,#20054,1,"b")
#20059=@"loc,{#10000},1,5,1,5"
locations_default(#20059,#10000,1,5,1,5)
hasLocation(#20058,#20059)
regexp_const_value(#20058,"b")
#20060=*
regexpterm(#20060,14,#20054,2,"c")
#20061=@"loc,{#10000},1,6,1,6"
locations_default(#20061,#10000,1,6,1,6)
hasLocation(#20060,#20061)
regexp_const_value(#20060,"c")
#20062=*
regexpterm(#20062,14,#20052,1,"&")
#20063=@"loc,{#10000},1,8,1,8"
locations_default(#20063,#10000,1,8,1,8)
hasLocation(#20062,#20063)
regexp_const_value(#20062,"&")
#20064=*
regexpterm(#20064,14,#20052,2,"&")
#20065=@"loc,{#10000},1,9,1,9"
locations_default(#20065,#10000,1,9,1,9)
hasLocation(#20064,#20065)
regexp_const_value(#20064,"&")
#20066=*
regexpterm(#20066,23,#20052,3,"[bcd]")
#20067=@"loc,{#10000},1,10,1,14"
locations_default(#20067,#10000,1,10,1,14)
hasLocation(#20066,#20067)
#20068=*
regexpterm(#20068,14,#20066,0,"b")
#20069=@"loc,{#10000},1,11,1,11"
locations_default(#20069,#10000,1,11,1,11)
hasLocation(#20068,#20069)
regexp_const_value(#20068,"b")
#20070=*
regexpterm(#20070,14,#20066,1,"c")
#20071=@"loc,{#10000},1,12,1,12"
locations_default(#20071,#10000,1,12,1,12)
hasLocation(#20070,#20071)
regexp_const_value(#20070,"c")
#20072=*
regexpterm(#20072,14,#20066,2,"d")
#20073=@"loc,{#10000},1,13,1,13"
locations_default(#20073,#10000,1,13,1,13)
hasLocation(#20072,#20073)
regexp_const_value(#20072,"d")
#20074=*
stmts(#20074,2,#20001,1,"/abc&&bcd/v;")
#20075=@"loc,{#10000},2,1,2,12"
locations_default(#20075,#10000,2,1,2,12)
hasLocation(#20074,#20075)
stmt_containers(#20074,#20001)
#20076=*
exprs(#20076,5,#20074,0,"/abc&&bcd/v")
hasLocation(#20076,#20035)
enclosing_stmt(#20076,#20074)
expr_containers(#20076,#20001)
literals("/abc&&bcd/v","/abc&&bcd/v",#20076)
#20077=*
regexpterm(#20077,14,#20076,0,"abc&&bcd")
#20078=@"loc,{#10000},2,2,2,9"
locations_default(#20078,#10000,2,2,2,9)
hasLocation(#20077,#20078)
regexp_const_value(#20077,"abc&&bcd")
#20079=*
stmts(#20079,2,#20001,2,"/[abc]&&[bcd]/v;")
#20080=@"loc,{#10000},3,1,3,16"
locations_default(#20080,#10000,3,1,3,16)
hasLocation(#20079,#20080)
stmt_containers(#20079,#20001)
#20081=*
exprs(#20081,5,#20079,0,"/[abc]&&[bcd]/v")
hasLocation(#20081,#20039)
enclosing_stmt(#20081,#20079)
expr_containers(#20081,#20001)
literals("/[abc]&&[bcd]/v","/[abc]&&[bcd]/v",#20081)
#20082=*
regexpterm(#20082,1,#20081,0,"[abc]&&[bcd]")
#20083=@"loc,{#10000},3,2,3,13"
locations_default(#20083,#10000,3,2,3,13)
hasLocation(#20082,#20083)
#20084=*
regexpterm(#20084,23,#20082,0,"[abc]")
#20085=@"loc,{#10000},3,2,3,6"
locations_default(#20085,#10000,3,2,3,6)
hasLocation(#20084,#20085)
#20086=*
regexpterm(#20086,14,#20084,0,"a")
#20087=@"loc,{#10000},3,3,3,3"
locations_default(#20087,#10000,3,3,3,3)
hasLocation(#20086,#20087)
regexp_const_value(#20086,"a")
#20088=*
regexpterm(#20088,14,#20084,1,"b")
#20089=@"loc,{#10000},3,4,3,4"
locations_default(#20089,#10000,3,4,3,4)
hasLocation(#20088,#20089)
regexp_const_value(#20088,"b")
#20090=*
regexpterm(#20090,14,#20084,2,"c")
#20091=@"loc,{#10000},3,5,3,5"
locations_default(#20091,#10000,3,5,3,5)
hasLocation(#20090,#20091)
regexp_const_value(#20090,"c")
#20092=*
regexpterm(#20092,14,#20082,1,"&&")
#20093=@"loc,{#10000},3,7,3,8"
locations_default(#20093,#10000,3,7,3,8)
hasLocation(#20092,#20093)
regexp_const_value(#20092,"&&")
#20094=*
regexpterm(#20094,23,#20082,2,"[bcd]")
#20095=@"loc,{#10000},3,9,3,13"
locations_default(#20095,#10000,3,9,3,13)
hasLocation(#20094,#20095)
#20096=*
regexpterm(#20096,14,#20094,0,"b")
#20097=@"loc,{#10000},3,10,3,10"
locations_default(#20097,#10000,3,10,3,10)
hasLocation(#20096,#20097)
regexp_const_value(#20096,"b")
#20098=*
regexpterm(#20098,14,#20094,1,"c")
#20099=@"loc,{#10000},3,11,3,11"
locations_default(#20099,#10000,3,11,3,11)
hasLocation(#20098,#20099)
regexp_const_value(#20098,"c")
#20100=*
regexpterm(#20100,14,#20094,2,"d")
#20101=@"loc,{#10000},3,12,3,12"
locations_default(#20101,#10000,3,12,3,12)
hasLocation(#20100,#20101)
regexp_const_value(#20100,"d")
#20102=*
stmts(#20102,2,#20001,3,"/[[abc] ... [c]]/v;")
#20103=@"loc,{#10000},7,1,7,23"
locations_default(#20103,#10000,7,1,7,23)
hasLocation(#20102,#20103)
stmt_containers(#20102,#20001)
#20104=*
exprs(#20104,5,#20102,0,"/[[abc] ... &[c]]/v")
hasLocation(#20104,#20043)
enclosing_stmt(#20104,#20102)
expr_containers(#20104,#20001)
literals("/[[abc]&&[bcd]&&[c]]/v","/[[abc]&&[bcd]&&[c]]/v",#20104)
#20105=*
regexpterm(#20105,23,#20104,0,"[[abc]&&[bcd]&&[c]]")
#20106=@"loc,{#10000},7,2,7,20"
locations_default(#20106,#10000,7,2,7,20)
hasLocation(#20105,#20106)
#20107=*
regexpterm(#20107,23,#20105,0,"[abc]")
#20108=@"loc,{#10000},7,3,7,7"
locations_default(#20108,#10000,7,3,7,7)
hasLocation(#20107,#20108)
#20109=*
regexpterm(#20109,14,#20107,0,"a")
#20110=@"loc,{#10000},7,4,7,4"
locations_default(#20110,#10000,7,4,7,4)
hasLocation(#20109,#20110)
regexp_const_value(#20109,"a")
#20111=*
regexpterm(#20111,14,#20107,1,"b")
#20112=@"loc,{#10000},7,5,7,5"
locations_default(#20112,#10000,7,5,7,5)
hasLocation(#20111,#20112)
regexp_const_value(#20111,"b")
#20113=*
regexpterm(#20113,14,#20107,2,"c")
#20114=@"loc,{#10000},7,6,7,6"
locations_default(#20114,#10000,7,6,7,6)
hasLocation(#20113,#20114)
regexp_const_value(#20113,"c")
#20115=*
regexpterm(#20115,14,#20105,1,"&")
#20116=@"loc,{#10000},7,8,7,8"
locations_default(#20116,#10000,7,8,7,8)
hasLocation(#20115,#20116)
regexp_const_value(#20115,"&")
#20117=*
regexpterm(#20117,14,#20105,2,"&")
#20118=@"loc,{#10000},7,9,7,9"
locations_default(#20118,#10000,7,9,7,9)
hasLocation(#20117,#20118)
regexp_const_value(#20117,"&")
#20119=*
regexpterm(#20119,23,#20105,3,"[bcd]")
#20120=@"loc,{#10000},7,10,7,14"
locations_default(#20120,#10000,7,10,7,14)
hasLocation(#20119,#20120)
#20121=*
regexpterm(#20121,14,#20119,0,"b")
#20122=@"loc,{#10000},7,11,7,11"
locations_default(#20122,#10000,7,11,7,11)
hasLocation(#20121,#20122)
regexp_const_value(#20121,"b")
#20123=*
regexpterm(#20123,14,#20119,1,"c")
#20124=@"loc,{#10000},7,12,7,12"
locations_default(#20124,#10000,7,12,7,12)
hasLocation(#20123,#20124)
regexp_const_value(#20123,"c")
#20125=*
regexpterm(#20125,14,#20119,2,"d")
#20126=@"loc,{#10000},7,13,7,13"
locations_default(#20126,#10000,7,13,7,13)
hasLocation(#20125,#20126)
regexp_const_value(#20125,"d")
#20127=*
regexpterm(#20127,14,#20105,4,"&")
#20128=@"loc,{#10000},7,15,7,15"
locations_default(#20128,#10000,7,15,7,15)
hasLocation(#20127,#20128)
regexp_const_value(#20127,"&")
#20129=*
regexpterm(#20129,14,#20105,5,"&")
#20130=@"loc,{#10000},7,16,7,16"
locations_default(#20130,#10000,7,16,7,16)
hasLocation(#20129,#20130)
regexp_const_value(#20129,"&")
#20131=*
regexpterm(#20131,23,#20105,6,"[c]")
#20132=@"loc,{#10000},7,17,7,19"
locations_default(#20132,#10000,7,17,7,19)
hasLocation(#20131,#20132)
#20133=*
regexpterm(#20133,14,#20131,0,"c")
#20134=@"loc,{#10000},7,18,7,18"
locations_default(#20134,#10000,7,18,7,18)
hasLocation(#20133,#20134)
regexp_const_value(#20133,"c")
#20135=*
entry_cfg_node(#20135,#20001)
#20136=@"loc,{#10000},1,1,1,0"
locations_default(#20136,#10000,1,1,1,0)
hasLocation(#20135,#20136)
#20137=*
exit_cfg_node(#20137,#20001)
hasLocation(#20137,#20047)
successor(#20102,#20104)
successor(#20104,#20137)
successor(#20079,#20081)
successor(#20081,#20102)
successor(#20074,#20076)
successor(#20076,#20079)
successor(#20049,#20051)
successor(#20051,#20074)
successor(#20135,#20049)
numlines(#10000,7,4,7)
filetype(#10000,"javascript")