Skip to content

Commit

Permalink
Added tests for spec versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnaldo committed Feb 25, 2022
1 parent d561212 commit 1c44bb4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/esmeta/spec/Spec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ case class Spec(
lazy val stats: Stats = new Stats(this)
}
object Spec:
case class Version(name: String, hash: String)
case class Version(name: String, hash: String) extends SpecElem
1 change: 1 addition & 0 deletions src/main/scala/esmeta/spec/util/Stringifier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ object Stringifier {
given elemRule: Rule[SpecElem] = (app, elem) =>
elem match {
case elem: Spec => specRule(app, elem)
case elem: Spec.Version => versionRule(app, elem)
case elem: Grammar => grammarRule(app, elem)
case elem: Production => prodRule(app, elem)
case elem: Lhs => lhsRule(app, elem)
Expand Down
9 changes: 9 additions & 0 deletions src/test/scala/esmeta/spec/StringifyTinyTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ class StringifyTinyTest extends SpecTest {

// registration
def init: Unit = {
// -------------------------------------------------------------------------
// Spec Version
// -------------------------------------------------------------------------
lazy val version = Spec.Version("1fc323b", "1fc323b")
lazy val namedVersion = Spec.Version("main", "1fc323b")
checkStringify("Spec.Version")(
version -> "1fc323b",
namedVersion -> "1fc323b (main)",
)
// -------------------------------------------------------------------------
// Grammar
// -------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion tests/result/spec/StringifyTinyTest
Original file line number Diff line number Diff line change
@@ -1 +1 @@
spec.StringifyTinyTest: 9 / 9
spec.StringifyTinyTest: 10 / 10
1 change: 1 addition & 0 deletions tests/result/spec/StringifyTinyTest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"Production.Kind" : true,
"Rhs" : true,
"RhsCond" : true,
"Spec.Version" : true,
"Symbol" : true
}

0 comments on commit 1c44bb4

Please sign in to comment.