Commits

Anonymous committed 2ef05ca

handle metadata on vectors, too and lessen the dependency of tests on clojure.core

Comments (0)

Files changed (2)

  make-clojure-map clojure-map? clojure-map-entries
 
  make-clojure-vector clojure-vector? clojure-vector-elements
+ clojure-vector-meta
 
  clojure-extend clojure-gensym clojure-new clojure-nil?
 
  +unbound+
 
- <clojure-object> <clojure-symbol> <clojure-var> <clojure-nil>)
+ <clojure-object> <clojure-symbol>
+ <clojure-var> <clojure-nil>
+ <clojure-vector>)
 
 (import chicken scheme)
 (use sexpressive sexpressive-clojure srfi-69
         (~list
          . ,(map (lambda (x)
                    `(~cons ,(car x) ,(cdr x)))
-                 (clojure-map-entries form))))))
+                 (clojure-map-entries form)))
+        ,(clojure-map-meta form))))
     ((? clojure-vector?)
      `(~make-clojure-vector
-       (~list . ,(map clojure-compile (clojure-vector-elements form)))))
+       (~list . ,(map clojure-compile (clojure-vector-elements form)))
+       ,(clojure-compile (clojure-vector-meta form))))
     ((? clojure-keyword?)
      (compile-keyword form))
     ((? clojure-symbol? sym)
   (test* "hello, world." "((fn* [x] (str \"hello, \" x \".\")) \"world\")")
   (test* #t "(fn? prn)")
   (test-group "rest argument"
-    (test* '(1 2 3) "((fn* [x & y] (cons x y)) 1 2 3)")
+    (test* '(1 2 3) "((fn* [x & y] (scheme/cons x y)) 1 2 3)")
     (test* '(1 2 3) "((fn* [& x] x) 1 2 3)")
     (test-error* "(fn* [&] 1)")
     (test-error* "(fn* [& x y] 1)")
   (test-group "arity overloading"
     (test* '(1 2 (3))
            "(def bar (fn* ([] 1) ([x] x) ([x & y] y)))"
-           "(list (bar) (bar 2) (bar 2 3))"))
+           "(scheme/list (bar) (bar 2) (bar 2 3))"))
   (test-group "named"
     (test* 4 "((fn* self ([x] (self x x)) ([x y] (+ x y))) 2)"))
   (test-group "recur"
     (test* "ok" "((fn* [x] (if (scheme/= x 0) \"ok\" (recur (- x 1)))) 10)"))
   (test* '(1 2)
          "(def x 1)"
-         "((fn* [x] (list user/x x)) 2)"))
+         "((fn* [x] (scheme/list user/x x)) 2)"))
 
 (test-group "syntax-quote"
   (test* (make-clojure-symbol 'user 'bar) "`bar")
   (test-error* "(let* [true 1 false 2 nil 3] true)")
   (test* '(1 2)
          "(def x 1)"
-         "(let* [x 2] (list user/x x))"))
+         "(let* [x 2] (scheme/list user/x x))"))
 
 (test-group "if, or, and"
   (test* 'nil "(or)")
          "(extend-type Symbol"
          "  Bar"
          "  (bar ([x] 1) ([x y] 2)))"
-         "(list (bar 'hey) (bar 'ho 'ho))"))
+         "(scheme/list (bar 'hey) (bar 'ho 'ho))"))
 
 (test-group "vars"
   (test-error* "#'asdlkajsldf"))
   (test* "baz"
          "(def ^:macro foo (fn* [x] `(def ~x)))"
          "(foo ^{:bar \"baz\"} qux)"
-         "(get (meta (var qux)) :bar)"))
+         "(get (meta (var qux)) :bar)")
+  (test* 3 "(get (meta ^{:foo (+ 1 2)} []) :foo)"))
 
 (test-group "loop*, recur"
   (test* 120
   (test* 'nil "(Nil.)")
   (test* '(#t #f)
          "(let [x \"foo\"]"
-         "  (list"
+         "  (scheme/list"
          "   (identical? x x)"
          "   (identical? x (String. x))))"))
 
   (test* '(1 2)
          "(deftype Foo [bar baz])"
          "(def foo (Foo. 1 2))"
-         "(list (.bar foo) (.baz foo))"))
+         "(scheme/list (.bar foo) (.baz foo))"))
 
 (test-group "private vars"
   (test-error*
          "(binding [foo 10] (bar))")
   (test* '(123 10)
          "(def ^:dynamic foo 123)"
-         "(list foo (binding [foo 10] foo))")
+         "(scheme/list foo (binding [foo 10] foo))")
   (test* '(99 99)
          "(def ^:dynamic foo 123)"
-         "(let [foo 99 bar foo] (list foo bar))"))
+         "(let [foo 99 bar foo] (scheme/list foo bar))"))
 
 (test-group "scheme*"
   (test* '^foo "(scheme* \"'^foo\")")