Add test for #12788
authorRyan Scott <ryan.gl.scott@gmail.com>
Thu, 3 Nov 2016 18:01:54 +0000 (14:01 -0400)
committerRyan Scott <ryan.gl.scott@gmail.com>
Thu, 3 Nov 2016 18:01:54 +0000 (14:01 -0400)
Commit bce99086e9f54909f51ff5a74cb8c666083bb021 (#12584) fixed #12788. Let's
add a test to make sure it stays fixed.

testsuite/tests/th/T12788.hs [new file with mode: 0644]
testsuite/tests/th/T12788.stderr [new file with mode: 0644]
testsuite/tests/th/T12788_Lib.hs [new file with mode: 0644]
testsuite/tests/th/all.T

diff --git a/testsuite/tests/th/T12788.hs b/testsuite/tests/th/T12788.hs
new file mode 100644 (file)
index 0000000..dc13c4f
--- /dev/null
@@ -0,0 +1,9 @@
+{-# LANGUAGE TemplateHaskell #-}
+module T12788 where
+
+import Language.Haskell.TH
+import T12788_Lib
+
+data Bad = Bad { _bad :: String } deriving (Eq, Ord, Show)
+
+$(deriveJSON defaultOptions{} ''Bad)
diff --git a/testsuite/tests/th/T12788.stderr b/testsuite/tests/th/T12788.stderr
new file mode 100644 (file)
index 0000000..485b200
--- /dev/null
@@ -0,0 +1,2 @@
+
+T12788.hs:9:14: error: Empty record update
diff --git a/testsuite/tests/th/T12788_Lib.hs b/testsuite/tests/th/T12788_Lib.hs
new file mode 100644 (file)
index 0000000..2924eef
--- /dev/null
@@ -0,0 +1,22 @@
+module T12788_Lib where
+
+import Language.Haskell.TH
+
+data Options = Options
+    { fieldLabelModifier :: String -> String
+    , constructorTagModifier :: String -> String
+    , allNullaryToStringTag :: Bool
+    , omitNothingFields :: Bool
+    , sumEncoding :: SumEncoding
+    , unwrapUnaryRecords :: Bool
+    }
+
+data SumEncoding =
+    TaggedObject { tagFieldName      :: String
+                 , contentsFieldName :: String
+                 }
+  | ObjectWithSingleField
+  | TwoElemArray
+
+deriveJSON :: Options -> Name -> Q [Dec]
+deriveJSON _ _ = return []
index b2aee12..4f21121 100644 (file)
@@ -433,3 +433,6 @@ test('T12478_3', omit_ways(['ghci']), compile, ['-v0'])
 test('T12478_4', omit_ways(['ghci']), compile_fail, ['-v0'])
 test('T12513', omit_ways(['ghci']), compile_fail, ['-v0'])
 test('T12530', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
+test('T12788', extra_clean(['T12788_Lib.hi', 'T12788_Lib.o']),
+               multimod_compile_fail,
+               ['T12788.hs', '-v0 ' + config.ghc_th_way_flags])