Skip to content

Commit

Permalink
Add failing test for purescript compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
aij committed Jun 27, 2019
1 parent 5b7c9ee commit 2a029ed
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 14 deletions.
8 changes: 7 additions & 1 deletion runtests
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e -x

pulp test
pulp build

case $1 in
ccap)
Expand Down Expand Up @@ -31,3 +31,9 @@ for i in samples/*.tmpl; do

# TODO: Test compilation of generated output.
done

# We can at least test compile this one for now

./compile -p Test.Generated -m purs -o test/generated samples/SelfContained.tmpl

pulp test
19 changes: 6 additions & 13 deletions samples/County.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ module County /* <scala package="gov.wicourts.codegen"> <purs modulePrefix="Ccap
type AssessFacilityId: wrap Int
type SomethingMoney: wrap Decimal

type Bunnies: wrap Int
<purs
t="Test.Support.Newint.Newint"
decode="Data.Newtype.wrap"
encode="Data.Newtype.unwrap">

type County: {
countyNo: Domains.CountyNoT
countyNoX: CountyNo
Expand Down Expand Up @@ -66,17 +72,4 @@ module County /* <scala package="gov.wicourts.codegen"> <purs modulePrefix="Ccap
| Etc
]

// A date, encoded per RFC 3339.
type Date: wrap String
<validations maxLength="32">
<scala
t="org.joda.time.LocalDate"
decode="Decoder.date"
encode="gov.wicourts.common.LocalDateOps.sortableDateFormat.print">
<purs
t="Ccap.Common.DateTime.Date.Date"
decode="Ccap.Common.DateTime.Date.decodeIsoMadison"
encode="Ccap.Common.DateTime.Date.inIso8601ExtendedDateFormat">

type Mydate: wrap Date
}
54 changes: 54 additions & 0 deletions samples/SelfContained.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// A self-contained example that we can compile without additional
// dependencies.
module SelfContained {
type CountyNo: Int
type CountyName: String <validations maxLength="32">
type OtherCountyName: wrap String <validations maxLength="32">
type AssessFacilityId: wrap Int
type SomethingMoney: wrap Decimal

// We can wrap a type in a pre-existing newtype
type Bunnies: wrap Int
<purs
t="Test.Support.Newint"
decode="Data.Newtype.wrap"
encode="Data.Newtype.unwrap">

type County: {
countyNo: CountyNo
countyName: CountyName
assessFacilityId: Maybe AssessFacilityId
soapPort: Int
}

type Big: {
a1: Int
b1: String
c1: Decimal
d1: Boolean
a2: Int
b2: String
c2: Decimal
d2: Boolean
a3: Int
b3: String
c3: Decimal
d3: Boolean
a4: Int
b4: String
c4: Decimal
d4: Boolean
}

type Response: {
counties: Array County
}

type CountyEnum: [
| Adams
| Ashland
| Baron
| Etc
]

}
7 changes: 7 additions & 0 deletions test/Support.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Test.Support where

import Data.Newtype

newtype Newint = Newint Int

derive instance newtypeNewint :: Newtype Newint _

0 comments on commit 2a029ed

Please sign in to comment.