From 6732f8f2ccb5cfd371065f041b9ced5cca0d79e5 Mon Sep 17 00:00:00 2001 From: InversionSpaces Date: Thu, 14 Dec 2023 10:27:14 +0100 Subject: [PATCH] fix(tests): Lower tests size (#1018) * Lower tests size * Remove prints --- io/src/test/scala/aqua/ImportsSpec.scala | 16 ++++++++++------ .../src/test/scala/aqua/lsp/AquaLSPSpec.scala | 11 ++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/io/src/test/scala/aqua/ImportsSpec.scala b/io/src/test/scala/aqua/ImportsSpec.scala index 36b40b3b..c463fd1b 100644 --- a/io/src/test/scala/aqua/ImportsSpec.scala +++ b/io/src/test/scala/aqua/ImportsSpec.scala @@ -11,11 +11,11 @@ class ImportsSpec extends AnyFlatSpec with ScalaCheckPropertyChecks with Matcher implicit override val generatorDrivenConfig = // Tests here are lightweight, so we can afford to run more of them - PropertyCheckConfiguration(minSuccessful = 500) + PropertyCheckConfiguration(minSuccessful = 500, sizeRange = 64) val shortAlphaNumStr = for { length <- Gen.choose(1, 10) - chars <- Gen.listOfN(5, Gen.alphaNumChar) + chars <- Gen.listOfN(length, Gen.alphaNumChar) } yield chars.mkString val fileNameWithExt = Gen @@ -29,7 +29,7 @@ class ImportsSpec extends AnyFlatSpec with ScalaCheckPropertyChecks with Matcher Gen.sized(size => for { segments <- Gen.listOfN( - size / 5, + size, Gen.oneOf( shortAlphaNumStr, Gen.oneOf(".", "..") @@ -49,7 +49,7 @@ class ImportsSpec extends AnyFlatSpec with ScalaCheckPropertyChecks with Matcher val simplePath: Gen[Path] = Gen.sized(size => for { segments <- Gen.listOfN( - size / 5, + size, shortAlphaNumStr ) suffix <- Gen.option( @@ -88,8 +88,12 @@ class ImportsSpec extends AnyFlatSpec with ScalaCheckPropertyChecks with Matcher }.map(Imports.apply) ) - val nonEmptyAsciiPrintableStr: Gen[String] = - Gen.nonEmptyListOf(Gen.asciiPrintableChar).map(_.mkString) + val nonEmptyAsciiPrintableStr: Gen[String] = Gen.sized(size => + for { + head <- Gen.asciiPrintableChar + tail <- Gen.listOfN(size, Gen.asciiPrintableChar) + } yield (head +: tail).mkString + ) "Imports" should "resolve relative import first" in { forAll( diff --git a/language-server/language-server-api/src/test/scala/aqua/lsp/AquaLSPSpec.scala b/language-server/language-server-api/src/test/scala/aqua/lsp/AquaLSPSpec.scala index cbb0d075..b490a889 100644 --- a/language-server/language-server-api/src/test/scala/aqua/lsp/AquaLSPSpec.scala +++ b/language-server/language-server-api/src/test/scala/aqua/lsp/AquaLSPSpec.scala @@ -200,7 +200,7 @@ class AquaLSPSpec extends AnyFlatSpec with Matchers with Inside { res.checkTokenLoc(main, "fooResult", 0, ScalarType.string) shouldBe true res.checkLocations("fooResult", 0, 1, main) shouldBe true - res.checkTokenLoc(main, "someVar", 0, LiteralType.string, None, true) shouldBe true + res.checkTokenLoc(main, "someVar", 0, LiteralType.string, None) shouldBe true res.checkLocations("someVar", 0, 1, main) shouldBe true res.checkTokenLoc(main, "someVar", 2, LiteralType.unsigned) shouldBe true res.checkLocations("someVar", 2, 3, main) shouldBe true @@ -221,8 +221,7 @@ class AquaLSPSpec extends AnyFlatSpec with Matchers with Inside { "someField", 0, ScalarType.u32, - Some("Ab.someField"), - true + Some("Ab.someField") ) shouldBe true // this is tokens from imports, if we will use `FileSpan.F` file names will be different @@ -233,8 +232,7 @@ class AquaLSPSpec extends AnyFlatSpec with Matchers with Inside { "more_call", 0, ArrowType(NilType, NilType), - Some("OneMore.more_call"), - true + Some("OneMore.more_call") ) shouldBe true res.checkTokenLoc( secondImport, @@ -253,8 +251,7 @@ class AquaLSPSpec extends AnyFlatSpec with Matchers with Inside { ProductType.labelled(("someVar", ScalarType.string) :: Nil), ProductType(ScalarType.string :: Nil) ), - None, - true + None ) shouldBe true res.checkTokenLoc(firstImport, "someVar", 0, ScalarType.string) shouldBe true