1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-21 10:37:58 +03:00
mal/js/tests/stepA_mal.mal
Dov Murik d953db84fc js: Fix interop, update web REPL page
* js* renamed to js-eval and is no longer a special form (just a normal
  function in core.js)
* . is no longer a special form (just a normal function in core.js)
* fixed object/method parsing of first argument to .
* added tests for .
* updated mal.html: "Mal at a glance" shows all Mal functions
2016-06-14 23:21:38 -04:00

40 lines
692 B
Plaintext

;; Testing basic bash interop
(js-eval "7")
;=>7
(js-eval "'7'")
;=>"7"
(js-eval "[7,8,9]")
;=>(7 8 9)
(js-eval "console.log('hello');")
; hello
;=>nil
(js-eval "foo=8;")
(js-eval "foo;")
;=>8
(js-eval "['a','b','c'].map(function(x){return 'X'+x+'Y'}).join(' ')")
;=>"XaY XbY XcY"
(js-eval "[1,2,3].map(function(x){return 1+x})")
;=>(2 3 4)
(js-eval (str "3 * " (* 4 5)))
;=>60
(. "console.log" "abc" 123 '(4 5 6) {"kk" "vv"} (= 1 1) nil)
; abc 123 [ 4, 5, 6 ] { kk: 'vv' } true null
;=>nil
(js-eval "myobj = { v: 10, myfunc: function(a,b,c) { return a * b * c * this.v; } }")
(. "myobj.myfunc" 2 3 4)
;=>240
(js-eval "myarray = [1,2,3,4,5]")
(. "myarray.join" "#")
;=>"1#2#3#4#5"