   (test-gen 'OP ['println 0] {:name 'println :n-args 0})
   (test-gen 'OP ['println 3] {:name 'println :n-args 3}))
 
-(defn add-unknown-source-info [inst]
-  (assoc inst :function :%unknown-function :source nil))
+(defn add-source-info [inst & {:keys [function source]
+                                       :or {function :%unknown-function
+                                            source nil}}]
+  (let [inst1 (if (:function inst)
+                inst
+                (assoc inst :function function))]
+    (if (:source inst1)
+      inst1
+      (assoc inst1 :source source))))
 
 (deftest gen-seq
   (is (= (riley/gen-seq) []))
   (is (= (riley/gen-seq (riley/gen 'LVAR 0 1 'x) (riley/gen 'GSET 'foo))
-         (map add-unknown-source-info
+         (map add-source-info
               [(vm/->LVAR 0 1 'x) (vm/->GSET 'foo)])))
     (is (= (riley/gen-seq [] (riley/gen 'LVAR 0 1 'y) [] (riley/gen 'GSET 'foo) [])
-         (map add-unknown-source-info
+         (map add-source-info
               [(vm/->LVAR 0 1 'y) (vm/->GSET 'foo)]))))
 
 (deftest gen-label

  (is (thrown? #+clj java.lang.AssertionError #+cljs js/Error
               (riley/gen-args 'foo '[a & 1]))))

;;; Evaluate this (e.g., with C-x C-e in Cider) to run the tests for
;;; this namespace:
;;; (t/run-tests 'revue.riley-test)


(deftest gen-args-1
  (is (= (riley/gen-args 'foo [])
         [(add-source-info (vm/->ARGS 0 'foo))]))
  (is (= (riley/gen-args 'foo '[a])
         [(add-source-info (vm/->ARGS 1 'foo))]))
  (is (= (riley/gen-args 'foo '[a b])
         [(add-source-info (vm/->ARGS 2 'foo))]))
  (is (= (riley/gen-args 'foo '[a b c])
         [(add-source-info (vm/->ARGS 3 'foo))]))
  (is (= (riley/gen-args 'foo '[& a])
         [(add-source-info (vm/->ARGS* 0 'foo))]))
  (is (= (riley/gen-args 'foo '[a & b])
         [(add-source-info (vm/->ARGS* 1 'foo))]))
  (is (= (riley/gen-args 'foo '[a b & c])
         [(add-source-info (vm/->ARGS* 2 'foo))]))
  (is (= (riley/gen-args 'foo '[a b c & c])
         [(add-source-info (vm/->ARGS* 3 'foo))])))

(deftest gen-args-2
  (is (thrown? #+clj java.lang.IllegalArgumentException #+cljs js/Error
