From 373931c728cd9769445c1e6180cb9a3be1490497 Mon Sep 17 00:00:00 2001
From: Alan Malloy <alan@malloys.org>
Date: Wed, 26 Oct 2011 12:05:41 -0700
Subject: [PATCH 1/2] Add test for macroexpansion metadata preservation

---
 test/clojure/test_clojure/macros.clj |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/test/clojure/test_clojure/macros.clj b/test/clojure/test_clojure/macros.clj
index 711130e..d17c499 100644
--- a/test/clojure/test_clojure/macros.clj
+++ b/test/clojure/test_clojure/macros.clj
@@ -9,10 +9,21 @@
 ; Author: Frantisek Sodomka
 
 (ns clojure.test-clojure.macros
-  (:use clojure.test))
+  (:use clojure.test)
+  (:import (java.util Map ArrayList)))
 
 ; http://clojure.org/macros
 
 ; ->
 ; defmacro definline macroexpand-1 macroexpand
 
+(defmacro simple-macro [f arg]
+  `(~f ~arg))
+
+(let [expanded (macroexpand ' ^Integer (simple-macro inc 1))]
+  ;; calling macroexpand inside of deftest is broken, so do it outside
+  (deftest preserve-meta
+    (testing "Manual expansion preserves metadata"
+      (is (= 'Integer (:tag (meta expanded)))))
+    (testing "Compiler preserves metadata"
+      (is (thrown? ClassCastException (.size ^Map (simple-macro identity (ArrayList.))))))))
-- 
1.7.4.1

