Skip to content

Commit

Permalink
Basic snapshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
keynmol committed Feb 18, 2024
1 parent 2bddcdb commit ebd16cd
Show file tree
Hide file tree
Showing 15 changed files with 276 additions and 95 deletions.
10 changes: 6 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,11 @@ lazy val lsp = projectMatrix
libraryDependencies += "com.lihaoyi" %%% "upickle" % V.upickle,
libraryDependencies += "org.typelevel" %%% "cats-core" % V.cats,
libraryDependencies += "tech.neander" %%% "jsonrpclib-core" % V.jsonrpclib,
test := {},
snapshotsPackageName := "tests.core"
test := {}
)
.jvmPlatform(V.scalaVersions)
.jsPlatform(V.scalaVersions)
.nativePlatform(V.scalaVersions)
.enablePlugins(SnapshotsPlugin)

lazy val app = projectMatrix
.in(file("modules/app"))
Expand Down Expand Up @@ -194,10 +192,14 @@ lazy val tests = projectMatrix
.settings(
libraryDependencies += "org.http4s" %% "http4s-jdk-http-client" % V.http4sJdkClient % Test,
libraryDependencies += "com.disneystreaming" %%% "weaver-cats" % V.weaver % Test,
libraryDependencies += "com.lihaoyi" %%% "pprint" % "0.7.0" % Test,
libraryDependencies += "org.typelevel" %% "shapeless3-deriving" % "3.4.1" % Test,
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.17.0" % Test,
Test / fork := virtualAxes.value.contains(VirtualAxis.jvm)
Test / fork := virtualAxes.value.contains(VirtualAxis.jvm),
snapshotsPackageName := "tests.core",
snapshotsForceOverwrite := !sys.env.contains("CI")
)
.enablePlugins(SnapshotsPlugin)

lazy val example = projectMatrix
.in(file("modules/example"))
Expand Down
13 changes: 7 additions & 6 deletions modules/lsp/src/main/scala/json.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,25 @@ private[lsp] object json:
val valueReader = upickle.default.readwriter[ujson.Value]
def badMerge[T](r1: => Reader[?], rest: Reader[?]*): Reader[T] =
valueReader.map { json =>
var t: T | Null = null
val stack = Vector.newBuilder[Throwable]
var t = Option.empty[T]
val stack = Vector.newBuilder[Throwable]

(r1 +: rest).foreach { reader =>
if t == null then
if t.isEmpty then
try
t =
t = Some(
read[T](json, trace = true)(using reader.asInstanceOf[Reader[T]])
)
catch
case exc =>
stack += exc
}
if t != null then t.nn
else
t.getOrElse(
throw new LangoustineError.FailureParsing(
json,
stack.result().headOption.getOrElse(null)
)
)
}

extension [T](r: Reader[T]) def widen[K >: T] = r.map(_.asInstanceOf[K])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
DocumentLinkParams(TextDocumentIdentifier(file1),凇뙑엸䝡럓젨돟딖墦삭痚Ù㡦뒹氯‸й⮴Պ鱀俘ཀྵ궐봒餥⵹脑唔釖ۑ韆◭摯㢥莟犒秳剴觞萦ឱ鿨ᑬ뒀懥剽㏿ᐥ᳟Ᵹ㌂犤雁駒瞧嫼ꐽꈉꜶ拁ꈁ뻓蠈떯ૹ釡䓚屚뇣豐铹꤀脋뒔竟F,봮ࠗ짔暧貤ⅻ䄙ꨮ碡듘敒溷텛甚惙휙꺢뮷찾ⲁ㐐驩瞶죊湪祸⻎ⅶ䩸妖ꙋ栋ꯈ졮焼ᤝ릌씓〡跿薽)
{"textDocument":{"uri":"file1"},"workDoneToken":"凇뙑엸䝡럓젨돟딖墦삭痚Ù㡦뒹氯‸й⮴Պ鱀俘ཀྵ궐봒餥⵹脑唔釖ۑ韆◭摯㢥莟犒秳剴觞萦ឱ鿨ᑬ뒀懥剽㏿ᐥ᳟Ᵹ㌂犤雁駒瞧嫼ꐽꈉꜶ拁ꈁ뻓蠈떯ૹ釡䓚屚뇣豐铹꤀脋뒔竟F","partialResultToken":"봮ࠗ짔暧貤ⅻ䄙ꨮ碡듘敒溷텛甚惙휙꺢뮷찾ⲁ㐐驩瞶죊湪祸⻎ⅶ䩸妖ꙋ栋ꯈ졮焼ᤝ릌씓〡跿薽"}
---------------------
DocumentLinkParams(TextDocumentIdentifier(file2),韵硠趣ꏱ黟滍떆੦혽㲰䬒↽Ṟᐫ꜀璬䍅뜝㻠・뒨뢾ᷓ,1534272523)
{"textDocument":{"uri":"file2"},"workDoneToken":"韵硠趣ꏱ黟滍떆੦혽㲰䬒↽Ṟᐫ꜀璬䍅뜝㻠・뒨뢾ᷓ","partialResultToken":1534272523}
---------------------
DocumentLinkParams(TextDocumentIdentifier(file1),1346632011,-2147483648)
{"textDocument":{"uri":"file1"},"workDoneToken":1346632011,"partialResultToken":-2147483648}
---------------------
DocumentLinkParams(TextDocumentIdentifier(file2),null,)
{"textDocument":{"uri":"file2"},"partialResultToken":""}
---------------------
DocumentLinkParams(TextDocumentIdentifier(file1),null,null)
{"textDocument":{"uri":"file1"}}
---------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
DocumentSymbolParams(TextDocumentIdentifier(file2),null,⨩|훠뱟慻ি퇖∷㟿㣥ꅟ儵ꆂ糏粇흱凘ꨴ骿ᑜ훗뱗渐姕Ạኹ᝱渻⛱픦͛뢋ᝦ暯ꣲ燦拘ⴝ뺰)
{"textDocument":{"uri":"file2"},"partialResultToken":"⨩|훠뱟慻ি퇖∷㟿㣥ꅟ儵ꆂ糏粇흱凘ꨴ骿ᑜ훗뱗渐姕Ạኹ᝱渻⛱픦͛뢋ᝦ暯ꣲ燦拘ⴝ뺰"}
---------------------
DocumentSymbolParams(TextDocumentIdentifier(file1),蕱흐퉖쵡⿷ሾ뚬䇹㰽Ղ惘횭捦顆른ꏧ䬂៯雚㻉뙻嫰說雄௯βי᧧㮳핅鏐暗쌦ᔇ䢩朓앾䴒ᔂ詻ش妉벩અ뻰ﲎ䤤歰荺㸩嬡䬾⫕兘蔄,null)
{"textDocument":{"uri":"file1"},"workDoneToken":"蕱흐퉖쵡⿷ሾ뚬䇹㰽Ղ惘횭捦顆른ꏧ䬂៯雚㻉뙻嫰說雄௯βי᧧㮳핅鏐暗쌦ᔇ䢩朓앾䴒ᔂ詻ش妉벩અ뻰ﲎ䤤歰荺㸩嬡䬾⫕兘蔄"}
---------------------
DocumentSymbolParams(TextDocumentIdentifier(file2),2147483647,-429001240)
{"textDocument":{"uri":"file2"},"workDoneToken":2147483647,"partialResultToken":-429001240}
---------------------
DocumentSymbolParams(TextDocumentIdentifier(file2),null,null)
{"textDocument":{"uri":"file2"}}
---------------------
DocumentSymbolParams(TextDocumentIdentifier(file2),null,-275211255)
{"textDocument":{"uri":"file2"},"partialResultToken":-275211255}
---------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FoldingRangeParams(TextDocumentIdentifier(file1),null,null)
{"textDocument":{"uri":"file1"}}
---------------------
FoldingRangeParams(TextDocumentIdentifier(file2),null,340346666)
{"textDocument":{"uri":"file2"},"partialResultToken":340346666}
---------------------
FoldingRangeParams(TextDocumentIdentifier(file1),2002172247,릏炶걭皵ꭗ㆑㶳˓ᯓ᯻㘗ᴢᅩꢅଢ଼㤵侃ۅ풃罹襒乣蜧飻訤鿌Ἇ쯑놬쵪銡䪰ᄌ⭼䥥媚荾ᗲ繾쉴䂷壄擄䀯豫ꓛ沏韩洦⼝ꇩ䪀Ąగ䐊࠰驂띈刺)
{"textDocument":{"uri":"file1"},"workDoneToken":2002172247,"partialResultToken":"릏炶걭皵ꭗ㆑㶳˓ᯓ᯻㘗ᴢᅩꢅଢ଼㤵侃ۅ풃罹襒乣蜧飻訤鿌Ἇ쯑놬쵪銡䪰ᄌ⭼䥥媚荾ᗲ繾쉴䂷壄擄䀯豫ꓛ沏韩洦⼝ꇩ䪀Ąగ䐊࠰驂띈刺"}
---------------------
FoldingRangeParams(TextDocumentIdentifier(file1),-2147483648,ҵ䭢罂ᒟⷒ竜툘揅ᄿ閥씾嘑쎼厱䧒䬠謔䲶钠蘔椹鑀鶒ﹺ愈滷꣧䧨୦এࣦ൞bޝࡖʩ縆檜삳㦺Ṅ鏀阊㋬衝躉繯⟊ᓺ䙞折많댮앵꜑Ľ꾃댪⯔4溡㬪ﳺ뺸⍵榴㌵研鴳羺䃹鐪鐍뙁ᘊ⫼㹫鋋酸ꗼ祺퇍甝䌍)
{"textDocument":{"uri":"file1"},"workDoneToken":-2147483648,"partialResultToken":"ҵ䭢罂ᒟⷒ竜툘揅ᄿ閥씾嘑쎼厱䧒䬠謔䲶钠蘔椹鑀鶒ﹺ愈滷꣧䧨୦এࣦ൞bޝࡖʩ縆檜삳㦺Ṅ鏀阊㋬衝躉繯⟊ᓺ䙞折많댮앵꜑Ľ꾃댪⯔4溡㬪ﳺ뺸⍵榴㌵研鴳羺䃹鐪鐍뙁ᘊ⫼㹫鋋酸ꗼ祺퇍甝䌍"}
---------------------
FoldingRangeParams(TextDocumentIdentifier(file1),null,null)
{"textDocument":{"uri":"file1"}}
---------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ReferenceParams(ReferenceContext(true),TextDocumentIdentifier(file2),Position(55,68),null,null)
{"context":{"includeDeclaration":true},"textDocument":{"uri":"file2"},"position":{"line":55,"character":68}}
---------------------
ReferenceParams(ReferenceContext(true),TextDocumentIdentifier(file1),Position(14,63),자墿潵/埜ꀇ獾ᱡ爵Ἆ῁䦟掰໌ӟ魙ࣱ䐌椥樤髜ꜙﬤ췓矍Ώ왚舞⡠췢셖狛̒଱☲唸檽먥⪺춭刐景しᄚ沓琜쀭뺮᧡틆牅舩኿﷎적錤쎬ﴎ碚缭バܾ챶ᑟ埠,-720406641)
{"context":{"includeDeclaration":true},"textDocument":{"uri":"file1"},"position":{"line":14,"character":63},"workDoneToken":"자墿潵/埜ꀇ獾ᱡ爵Ἆ῁䦟掰໌ӟ魙ࣱ䐌椥樤髜ꜙﬤ췓矍Ώ왚舞⡠췢셖狛̒଱☲唸檽먥⪺춭刐景しᄚ沓琜쀭뺮᧡틆牅舩኿﷎적錤쎬ﴎ碚缭バܾ챶ᑟ埠","partialResultToken":-720406641}
---------------------
ReferenceParams(ReferenceContext(true),TextDocumentIdentifier(file1),Position(18,50),-590955446,↺ퟶﺯࢊⷽ禚㑄劚韏졛䏠濍㬯ଇ類೉㪳圙黅汰檴㚜티랟鱛闃赀淶狼龒⏩ኙ䝕턇ꊚЉ湚皺㤖뎌ﴩ⮦앍⨿꟧樂낸㙲庑ꂂ榧ⓐ⑥趎Ǫ핾⬐럢⤛搰﯊ᴞ諍巧㛴䘜㰳䢹芍毂墖ꗶ둡ㅉ又䍡չ춃俓쿍쟺㏹ㄋካ婾딈)
{"context":{"includeDeclaration":true},"textDocument":{"uri":"file1"},"position":{"line":18,"character":50},"workDoneToken":-590955446,"partialResultToken":"↺ퟶﺯࢊⷽ禚㑄劚韏졛䏠濍㬯ଇ類೉㪳圙黅汰檴㚜티랟鱛闃赀淶狼龒⏩ኙ䝕턇ꊚЉ湚皺㤖뎌ﴩ⮦앍⨿꟧樂낸㙲庑ꂂ榧ⓐ⑥趎Ǫ핾⬐럢⤛搰﯊ᴞ諍巧㛴䘜㰳䢹芍毂墖ꗶ둡ㅉ又䍡չ춃俓쿍쟺㏹ㄋካ婾딈"}
---------------------
ReferenceParams(ReferenceContext(false),TextDocumentIdentifier(file2),Position(35,78),-1788505416,null)
{"context":{"includeDeclaration":false},"textDocument":{"uri":"file2"},"position":{"line":35,"character":78},"workDoneToken":-1788505416}
---------------------
ReferenceParams(ReferenceContext(false),TextDocumentIdentifier(file2),Position(85,93),null,null)
{"context":{"includeDeclaration":false},"textDocument":{"uri":"file2"},"position":{"line":85,"character":93}}
---------------------
Loading

0 comments on commit ebd16cd

Please sign in to comment.