Add basic interop and tests
authorVasilij Schneidermann <v.schneidermann@gmail.com>
Tue, 1 Mar 2016 23:55:55 +0000 (00:55 +0100)
committerVasilij Schneidermann <v.schneidermann@gmail.com>
Tue, 1 Mar 2016 23:55:55 +0000 (00:55 +0100)
elisp/stepA_mal.el
elisp/tests/stepA_mal.mal [new file with mode: 0644]

index 929a239..f0efdce 100644 (file)
             (throw 'return (mal-env-set env identifier value))))
          ((eq a0* 'macroexpand)
           (throw 'return (MACROEXPAND a1 env)))
+         ((eq a0* 'elisp*)
+          (throw 'return (mal-string (format "%S" (eval (read (mal-value a1)))))))
          ((eq a0* 'try*)
           (condition-case err
               (throw 'return (EVAL a1 env))
diff --git a/elisp/tests/stepA_mal.mal b/elisp/tests/stepA_mal.mal
new file mode 100644 (file)
index 0000000..420101b
--- /dev/null
@@ -0,0 +1,21 @@
+;; Testing basic elisp interop
+
+(elisp* "42")
+;=>"42"
+
+(elisp* "(+ 1 1)")
+;=>"2"
+
+(elisp* "[foo bar baz]")
+;=>"[foo bar baz]"
+
+(elisp* "(mapcar '1+ (number-sequence 0 2))")
+;=>"(1 2 3)"
+
+(elisp* "(progn (princ \"Hello World!\n\") nil)")
+; Hello World!
+;=>"nil"
+
+(elisp* "(setq emacs-version-re \"24\\\.[[:digit:]]\\\.[[:digit:]]\")")
+(elisp* "(and (string-match-p emacs-version-re emacs-version) t)")
+;=>"t"