Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
winitzki committed Jun 24, 2024
1 parent 24b7331 commit b620035
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,26 @@ class SimpleSemanticsTest extends DhallTest {
expect(!Semantics.equivalent(x, y))
}

test("with for Optional works if it does not change type") { // https://github.com/dhall-lang/dhall-haskell/issues/2597
test("`with` for Optional works if it does not change type") { // https://github.com/dhall-lang/dhall-haskell/issues/2597
val result = "(Some 1) with ? = 2".dhall.typeCheckAndBetaNormalize()
expect(result.unsafeGet.print == "Some 2")
}

test("fail `with` for Optional if it changes type") {
val result = """(Some 1) with ? = "hello"""".dhall.typeCheckAndBetaNormalize()
expect(
Try(
result.unsafeGet
).failed.get.getMessage contains "Inferred type Text differs from the expected type Natural, expression under type inference: \"hello\""
)
}

test("`with` for Optional works if it does not change type, with deep record access") { // https://github.com/dhall-lang/dhall-haskell/issues/2597
val result = "(Some { x.y = 1 }) with ?.x.y = 2".dhall.typeCheckAndBetaNormalize()
expect(result.unsafeGet.print == "Some { x = 2 }")
}

test("with for Optional may not change type") {
test("fail `with` for Optional if it changes type, with deep record access") {
val result = """(Some { x.y = 1 }) with ?.x.y = "hello"""".dhall.typeCheckAndBetaNormalize()
expect(
Try(
Expand Down

0 comments on commit b620035

Please sign in to comment.