Skip to content

Commit

Permalink
Merge pull request #1595 from Vyxal/v3-tests-yaml
Browse files Browse the repository at this point in the history
Create tests.yaml and an accompanying test suite
  • Loading branch information
ysthakur committed May 24, 2023
2 parents 8304cc6 + 8b30620 commit 336802e
Show file tree
Hide file tree
Showing 18 changed files with 258 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Expand Up @@ -15,7 +15,7 @@ rewrite.scala3.removeEndMarkerMaxLines = 14
rewrite.rules = [Imports]
rewrite.imports.sort = original
# Any Vyxal imports go at the top
rewrite.imports.groups = [["vyxal\\..*"]]
rewrite.imports.groups = [["vyxal\\..*"], ["scala\\..*", "java\\..*"]]
rewrite.imports.contiguousGroups = no

rewrite.trailingCommas.style = keep # frick you removing my commas.
Expand Down
4 changes: 3 additions & 1 deletion build.sbt
Expand Up @@ -31,6 +31,8 @@ lazy val vyxal = crossProject(JSPlatform, JVMPlatform, NativePlatform)
"org.scala-lang.modules" %%% "scala-parser-combinators" % "2.2.0",
// For command line parsing
"com.github.scopt" %%% "scopt" % "4.1.0",
// For reading tests.yaml
"io.circe" %%% "circe-yaml" % "0.14.2" % Test,
// Used by ScalaTest
"org.scalactic" %%% "scalactic" % "3.2.15",
"org.scalatest" %%% "scalatest" % "3.2.15" % Test
Expand Down Expand Up @@ -61,7 +63,7 @@ lazy val vyxal = crossProject(JSPlatform, JVMPlatform, NativePlatform)
),
// From https://www.scalatest.org/user_guide/using_the_runner
// Suppress output from successful tests
Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oNCXELOPQRM")
Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oNCXELOPQRMF")
)
.jvmSettings(
// JVM-specific settings
Expand Down
11 changes: 9 additions & 2 deletions build.sc
Expand Up @@ -45,7 +45,10 @@ trait VyxalModule extends ScalaModule {
trait VyxalTestModule extends Tests with TestModule.ScalaTest {
def scalaVersion = VyxalModule.this.scalaVersion()

def ivyDeps = Agg(ivy"org.scalatest::scalatest:3.2.15")
def ivyDeps = Agg(
ivy"org.scalatest::scalatest:3.2.15",
ivy"io.circe::circe-yaml:0.14.2"
)

// Task to only show output from failed tests
def testQuiet(args: String*) =
Expand All @@ -66,7 +69,11 @@ trait VyxalModule extends ScalaModule {
object jvm extends VyxalModule {
def platform = "jvm"

object test extends VyxalTestModule
object test extends VyxalTestModule {
def ivyDeps = T {
super.ivyDeps() ++ Seq(ivy"org.yaml:snakeyaml::1.33")
}
}
}

/** Shared and JS-specific code */
Expand Down
3 changes: 2 additions & 1 deletion documentation/BuildTools.md
Expand Up @@ -194,7 +194,8 @@ def ivyDeps = Agg(
```

They are declared in a fashion very similar to sbt: `ivy"groupId::artifactId::version"`.
JVM-specific dependencies use a single colon between the group and artifact (`ivy"groupId:artifactId::version"`).

**Note**: Java dependencies use a single colon between the group and artifact (`ivy"groupId:artifactId::version"`).

---

Expand Down
1 change: 1 addition & 0 deletions shared/src/main/scala/Elements.scala
Expand Up @@ -7,6 +7,7 @@ import vyxal.*

import scala.io.StdIn
import scala.language.implicitConversions

import spire.algebra.*
import VNum.given

Expand Down
1 change: 1 addition & 0 deletions shared/src/main/scala/Globals.scala
@@ -1,6 +1,7 @@
package vyxal

import scala.io.StdIn

import VNum.given

/** Stuff that's shared across all contexts
Expand Down
1 change: 1 addition & 0 deletions shared/src/main/scala/Interpreter.scala
Expand Up @@ -6,6 +6,7 @@ import vyxal.MiscHelpers.{vyPrint, vyPrintln}
import scala.annotation.varargs
import scala.collection.mutable.ListBuffer
import scala.collection.mutable as mut

import VNum.given

object Interpreter:
Expand Down
1 change: 1 addition & 0 deletions shared/src/main/scala/Lexer.scala
Expand Up @@ -5,6 +5,7 @@ import vyxal.impls.Elements
import java.util.regex.Pattern
import scala.util.matching.Regex
import scala.util.parsing.combinator.*

import VyxalToken.*

case class VyxalCompilationError(msg: String)
Expand Down
3 changes: 2 additions & 1 deletion shared/src/main/scala/ListHelpers.scala
@@ -1,7 +1,8 @@
package vyxal

import collection.mutable.ArrayBuffer
import scala.collection.mutable as mut

import collection.mutable.ArrayBuffer
import VNum.given

object ListHelpers:
Expand Down
1 change: 1 addition & 0 deletions shared/src/main/scala/LiterateLexer.scala
Expand Up @@ -7,6 +7,7 @@ import scala.collection.mutable.ListBuffer
import scala.collection.mutable.Queue
import scala.util.matching.Regex
import scala.util.parsing.combinator.*

import LiterateToken.*

val lambdaKeywords = List(
Expand Down
1 change: 1 addition & 0 deletions shared/src/main/scala/MiscHelpers.scala
Expand Up @@ -6,6 +6,7 @@ import vyxal.VNum.given

import scala.collection.mutable.ListBuffer
import scala.collection.mutable.Stack

import spire.algebra.*

object MiscHelpers:
Expand Down
3 changes: 2 additions & 1 deletion shared/src/main/scala/StringHelpers.scala
@@ -1,9 +1,10 @@
package vyxal

import collection.mutable.StringBuilder
import scala.collection.mutable.ListBuffer
import scala.util.matching.Regex

import collection.mutable.StringBuilder

object StringHelpers:

def chrord(c: VAny): VAny =
Expand Down
1 change: 1 addition & 0 deletions shared/src/main/scala/VAny.scala
Expand Up @@ -5,6 +5,7 @@ import vyxal.Interpreter.executeFn

import scala.collection.mutable as mut
import scala.reflect.TypeTest

import spire.algebra.*
import spire.implicits.*
import spire.math.{Complex, Real}
Expand Down
11 changes: 6 additions & 5 deletions shared/src/main/scala/VList.scala
Expand Up @@ -2,9 +2,10 @@ package vyxal

import vyxal.VNum.given

import scala.collection.SpecificIterableFactory

import collection.immutable.SeqOps
import collection.mutable
import scala.collection.SpecificIterableFactory
import spire.algebra.*

/** A Vyxal list. It simply wraps around another list and could represent a
Expand Down Expand Up @@ -100,10 +101,10 @@ class VList private (val lst: Seq[VAny])
end VList

object VList extends SpecificIterableFactory[VAny, VList]:
def from(it: Seq[VAny]): VList =
if it.isInstanceOf[VList] then it
else new VList(it)

def from(it: Seq[VAny]): VList =
it match
case temp: VList => temp
case _ => new VList(it)

/** Zip multiple VLists together with a function.
*
Expand Down
1 change: 1 addition & 0 deletions shared/src/main/scala/VNum.scala
@@ -1,6 +1,7 @@
package vyxal

import scala.language.implicitConversions

import spire.implicits.partialOrderOps // For <, >, etc.
import spire.math.{Complex, Real}

Expand Down
1 change: 1 addition & 0 deletions shared/src/main/scala/cli/CLI.scala
Expand Up @@ -4,6 +4,7 @@ import vyxal.*
import vyxal.impls.{Element, Elements}

import java.io.File

import scopt.OParser

object CLI:
Expand Down
14 changes: 14 additions & 0 deletions shared/src/test/resources/tests.yaml
@@ -0,0 +1,14 @@
"+":
- { in: ["1", 2], out: "12" }
- { in: ["foo", "bar"], out: "foobar" }
- { in: [[1, "a", []], 3], out: [4, "a3", []] }

"-":
when given a string and a number:
- { in: ["Hello, World", 5], out: "Hello, World-----" }
- { in: ["Hello, World", 5.2], out: "Hello, World-----" }
- { in: ["Hello, World", -5], out: "-----Hello, World" }

"B":
shouldn't do string multiplication with string lists:
- { in: [["1", "0", ["0", "1"]]], out: 5 }

0 comments on commit 336802e

Please sign in to comment.