Skip to content

Commit

Permalink
Increase code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
fan-tom committed Jan 21, 2024
1 parent 7b925d2 commit e8c3b16
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package at.forsyte.apalache.io.quint

import at.forsyte.apalache.tla.lir.{IntT1, OperT1, RecRowT1, RowT1, SetT1, TlaEx, TlaType1, Typed, VarT1}
import at.forsyte.apalache.tla.lir.{
BoolT1, IntT1, OperT1, RecRowT1, RowT1, SetT1, TlaAssumeDecl, TlaEx, TlaType1, Typed, ValEx, VarT1,
}
import org.junit.runner.RunWith
import org.scalatest.funsuite.AnyFunSuite
import org.scalatestplus.junit.JUnitRunner
import QuintType._
import QuintEx._
import at.forsyte.apalache.io.quint.QuintDef.QuintAssume
import at.forsyte.apalache.tla.lir.values.TlaBool
import at.forsyte.apalache.tla.typecomp.build

// You can run all these tests in watch mode in the
Expand Down Expand Up @@ -789,4 +793,18 @@ class TestQuintEx extends AnyFunSuite {
val err = intercept[QuintIRParseError](convert(Q.oneOfSet))
assert(err.getMessage().contains("`oneOf` can only occur as the principle operator of a `nondet` declaration"))
}

test("can convert ASSUME declaration") {
val translator = new Quint(Q.quintOutput)
val nullaryOps = Set[String]()

val name = "myAssume"
val namedAssume = QuintAssume(1, name, QuintBool(2, true))
val tlaNamedAssumeDef = translator.tlaDef(namedAssume).run(nullaryOps).get._2
assert(tlaNamedAssumeDef == TlaAssumeDecl(Some(name), ValEx(TlaBool(true))(Typed(BoolT1)))(Typed(BoolT1)))

val unnamedAssume = QuintAssume(1, "_", QuintBool(2, true))
val tlaUnnamedAssumeDef = translator.tlaDef(unnamedAssume).run(nullaryOps).get._2
assert(tlaUnnamedAssumeDef == TlaAssumeDecl(None, ValEx(TlaBool(true))(Typed(BoolT1)))(Typed(BoolT1)))
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package at.forsyte.apalache.io.quint

import at.forsyte.apalache.io.quint.QuintDef.QuintAssume
import at.forsyte.apalache.io.quint.QuintEx.QuintBool
import org.junit.runner.RunWith
import org.scalatest.funsuite.AnyFunSuite
import org.scalatestplus.junit.JUnitRunner
Expand Down Expand Up @@ -37,6 +39,14 @@ class TestQuintIR extends AnyFunSuite {
assert(QuintDeserializer.write[BigInt](BigInt(s"-${someBigIntStr}")) == s"-${someBigIntStr}")
}

test("QuintAssume#isUnnamed works correctly") {
val namedAssume = QuintAssume(1, "myAssume", QuintBool(2, true))
assert(!namedAssume.isUnnamed)

val unnamedAssume = QuintAssume(1, "_", QuintBool(2, true))
assert(unnamedAssume.isUnnamed)
}

// tictactoe.json is located in tla-io/src/test/resources/tictactoe.json
test("Can load tictactoe.json") {
val tictactoeQuintJson = scala.io.Source.fromResource("tictactoe.json").mkString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ class TestPrinter extends AnyFunSuite with TestingPredefs {
}
}

test("Test UTF8: TlaAssumeDecl") {
val namedAssume: String = toUtf(TlaAssumeDecl(Some("myAssume"), tla.eql(tla.name("x"), tla.bool(true))))
assert(namedAssume == s"ASSUME myAssume ≜ x = TRUE")

val unnamedAssume: String = toUtf(TlaAssumeDecl(None, tla.eql(tla.name("x"), tla.bool(true))))
assert(unnamedAssume == s"ASSUME x = TRUE")
}

// regression
test("Test UTF8: OperFormalParam") {
val d = TlaOperDecl("Foo", List(OperParam("Bar", 1)), ValEx(TlaInt(1)))
Expand Down

0 comments on commit e8c3b16

Please sign in to comment.