Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
a9d20f4 Add test for generic deriving with awkward records (Harry Garrood, 54 seconds ago)
diff --git a/examples/passing/RecordLabels.purs b/examples/passing/RecordLabels.purs
new file mode 100644
index 0000000..b58a4bd
--- /dev/null
+++ b/examples/passing/RecordLabels.purs
@@ -0,0 +1,5 @@
+module Main where
+
+import RecordLabels as RecordLabels
+
+main = RecordLabels.main
diff --git a/examples/passing/RecordLabels/RecordLabels.purs b/examples/passing/RecordLabels/RecordLabels.purs
new file mode 100644
index 0000000..c3716db
--- /dev/null
+++ b/examples/passing/RecordLabels/RecordLabels.purs
@@ -0,0 +1,25 @@
+module RecordLabels where
+
+import Prelude
+import Data.Generic (class Generic, gShow)
+import Control.Monad.Eff.Console (log)
+import Test.Assert (assert')
+
+newtype AstralKeys = AstralKeys { "💡" :: Int, "💢" :: Int }
+newtype LoneSurrogateKeys = LoneSurrogateKeys { "\xdf06" :: Int, "\xd834" :: Int }
+
+derive instance genericAstralKeys :: Generic AstralKeys
+derive instance genericLoneSurrogateKeys :: Generic LoneSurrogateKeys
+
+loneSurrogateKeys =
+ gShow (LoneSurrogateKeys { "\xdf06": 0, "\xd834": 1 }) ==
+ """LoneSurrogateKeys { "\xdf06": 0, "\xd834": 1 }"""
+
+astralKeys =
+ gShow (AstralKeys { "💡": 0, "💢": 1 }) ==
+ """AstralKeys { "💡": 0, "💢": 1 }"""
+
+main = do
+ assert' "lone surrogate keys" loneSurrogateKeys
+ assert' "astral keys" astralKeys
+ log "Done"
diff --git a/tests/support/bower.json b/tests/support/bower.json
index c6a7173..aef7751 100644
--- a/tests/support/bower.json
+++ b/tests/support/bower.json
@@ -9,6 +9,7 @@
"purescript-st": "2.0.0",
"purescript-partial": "1.1.2",
"purescript-newtype": "1.1.0",
+ "purescript-generics": "3.3.0",
"purescript-generics-rep": "4.0.0",
"purescript-symbols": "^2.0.0",
"purescript-typelevel-prelude": "https://github.com/purescript/purescript-typelevel-prelude.git#29a7123a0c29c85d4b923fcf4a7df8e45ebf9bac",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.