Skip to content

Commit

Permalink
Add tests for nullability; add configuration option for requiring non
Browse files Browse the repository at this point in the history
nullable fields
  • Loading branch information
KacperFKorban committed Apr 11, 2024
1 parent fb38cee commit f719db8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions guinep/src/test/scala/formgentests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,17 @@ class FormGenTests extends munit.FunSuite {
)
)

checkGeneratedFormEquals(
"showNullableInt",
showNullableInt,
Form(
Seq(
FormElement.Nullable("i", FormElement.NumberInput("i", Types.IntType.Int))
),
Map.empty
)
)

checkGeneratedFormEquals(
"isInTree",
isInTree,
Expand Down
14 changes: 14 additions & 0 deletions guinep/src/test/scala/rungentests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,20 @@ class RunGenTests extends munit.FunSuite {
"6.0"
)

checkGeneratedRunResultEquals(
"showNullableInt",
showNullableInt,
List(null),
"null"
)

checkGeneratedRunResultEquals(
"showNullableInt",
showNullableInt,
List(1),
"1"
)

checkGeneratedRunResultEquals(
"isInTree",
isInTree,
Expand Down
3 changes: 3 additions & 0 deletions guinep/src/test/scala/testsdata.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ object TestsData {
def productSeq(s: Seq[Float]): Float =
s.product

def showNullableInt(i: Int | Null): String =
if i == null then "null" else i.toString

enum IntTree:
case Leaf
case Node(left: IntTree, value: Int, right: IntTree)
Expand Down

0 comments on commit f719db8

Please sign in to comment.